Slides adopted from T. Ferguson Spring 2016
|
|
- Clement Davidson
- 6 years ago
- Views:
Transcription
1 CSE1311 Introduction to Programming for Science & Engineering Students Mostafa Parchami, Ph.D. Dept. of Comp. Science and Eng., Univ. of Texas at Arlington, USA Slides adopted from T. Ferguson Spring 2016
2 Topics Boolean Expressions If Statement Switch Statement 2
3 Why do we need conditions? scanf("%d", &pressurevalue); while (pressurevalue <= MAX_PRESSURE) if (pressurevalue == NOMINAL_VALUE) printf("pressure is nominal\n"); else printf("pressure is %d pounds\n", pressurevalue); for (i = 5; i <= pressurevalue; i = i + 10) printf("+"); printf("\n"); scanf("%d", &pressurevalue); // End while 3
4 What is a conditional Expression? A conditional expression evaluates to a value of true or false These are the two values for the Boolean type named after the mathematician George Boole When a conditional expression is evaluated, it results in a value of type Boolean In the C programming language there is no explicit Boolean type. Instead, false is 0 and true is any non-zero value. Many C programs use a #define macro to set a Boolean variable to true or false #define FALSE 0 #define TRUE 1 Conditional expressions are also called Boolean expressions A conditional expression is used whenever a true or false decision needs to be made about the value of certain variables or constants in a program 4
5 Expression Contents A conditional expression in C may contain any valid mathematical expression It may also contain relational operators and logical operators In addition, it may contain one or more function calls that return a value 5
6 Relational Operators ==,!= Equivalent, Not equivalent <, <= Less than, Less than or equals >, >= Greater than, Greater than or equals if (A == B) C = 5; if (A!= B) C = 10; for (i = 0; i < MAX_INDEX; i++) printf("*"); if (A <= B) D = 20; while (A > B) B++; if (A >= B) D = 40; A = B <= C; D = A == B; 6
7 Logical Operators && Logical AND Logical OR! Logical NOT if ( (A == B) && (C <= D) ) E = 5; if ( (A!= B) (C >= D) ) F = 10; while (!(A == B) ) B++; if (!((A >= B) && (C <= D) (E!= F))) G = 100; A = B C; D = A && B; 7
8 Boolean Algebra if (0 0) printf("does false OR false = true?"); if (0 && 0) printf("does false AND false = true?"); 8
9 if, if-else, if-else-if // Variable can be char or int switch(<variable>) case <value1>: // variable==value1 case <value2>: // variable==value2 default: // variable!=value1 and variable!=value2 9
10 // Variable can be char or int switch(<variable>) case <value1>: // variable==value1 case <value2>: default: if(<condition1>) //Condition1 is true else if(<condition2>) // Condition1=false, Condition 2=true switch if(<condition>) //Condition is true else // Condition is false if(<condition1>) //Condition1 is true else if(<condition2>) // Condition1=false, Condition 2=true 10
11 Programming Examples 1) Read an integer and print Odd if the number is odd, print Even otherwise. 2) Read an integer and if it is positive print Positive, otherwise print Negative. 3) Read three numbers and print them in decreasing order. 4) Read a character and if the character is equal to + read two integers and print their sum. a, read two numbers and print the average. If the value is n, read one number negative of that number. If the value is e, do nothing. Otherwise, print Entered wrong character! ; 5) Read a character, if it was 1 or 2 or 3 or a or b, print Class A!. If the character was 4 or 5 or 6 or c or d, print Class B!. 11
12 Problem 1 /*A program that reads an integer is even!*/ #include <stdio.h> int main() int num; printf("please enter an integer: "); scanf("%d", &num); if (num % 2 == 0) // Is it even? printf("even"); else // Is not even? printf("odd"); return 0; 12
13 Problem 2 /*A program that reads an integer and checks if it is positive or negative!*/ #include <stdio.h> int main() int num; printf("please enter an integer: "); scanf("%d", &num); if (num > 0) // Is it positive? printf("positive"); else if (num < 0) // Is it negative? printf("negative"); else // Not positive or negative?! printf("zero!"); return 0; 13
14 Problem 3 14
15 // A simple calculator #include <stdio.h> Problem 4 int main() char ch; float num1, num2, average, sum, negative; printf("please enter the control character: "); scanf("%c", &ch); switch (ch) case '+': printf("please enter the first number: "); scanf("%f", &num1); printf("please enter the second number: "); scanf("%f", &num2); sum = num1 + num2; printf("the sum of %f and %f is: %f", num1, num2, sum); 15
16 Problem 4 return 0; case 'a': case 'n': case 'e': default: printf("please enter the first number: "); scanf("%f", &num1); printf("please enter the second number: "); scanf("%f", &num2); average = (num1 + num2)/2; printf("the average of %f and %f is: %f", num1, num2, average); printf("please enter the first number: "); scanf("%f", &num1); negative = -num1; printf("the negative of %f is: %f", num1, negative); printf("entered wrong character!"); 16
17 #include <stdio.h> Problem 5 int main() char ch; printf("please enter the control character: "); scanf("%c", &ch); switch (ch) case '1': case '2': case '3': case 'a': case 'b': printf("class A!"); case '4': case '5': case '6': case 'c': case 'd': printf("class B!"); return 0; 17
Slides adopted from T. Ferguson Spring 2016
CSE3 Introduction to Programming for Science & Engineering Students Mostafa Parchami, Ph.D. Dept. of Comp. Science and Eng., Univ. of Texas at Arlington, USA Slides adopted from T. Ferguson Spring 06 Pointers
More informationSlides adopted from T. Ferguson Spring 2016
CSE1311 Introduction to Programming for Science & Engineering Students Mostafa Parchami, Ph.D. Dept. of Comp. Science and Eng., Univ. of Texas at Arlington, USA Slides adopted from T. Ferguson Spring 2016
More informationIntroduction to Computing Lecture 07: Repetition and Loop Statements (Part II)
Introduction to Computing Lecture 07: Repetition and Loop Statements (Part II) Assist.Prof.Dr. Nükhet ÖZBEK Ege University Department of Electrical & Electronics Engineering nukhet.ozbek@ege.edu.tr Topics
More informationUNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING
UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING APS 105 Computer Fundamentals Midterm Examination October 20, 2011 6:15 p.m. 8:00 p.m. (105 minutes) Examiners: J. Anderson, T. Fairgrieve,
More informationIntroduction to C. Systems Programming Concepts
Introduction to C Systems Programming Concepts Introduction to C A simple C Program Variable Declarations printf ( ) Compiling and Running a C Program Sizeof Program #include What is True in C? if example
More information1. The keyword main in C language is used for
1. The keyword main in C language is used for a. an user defined function *b. the first function to be executed in the program c. an user defined variable 2. The role of a C compiler is to translate a.
More informationComputer Programming. Decision Making (2) Loops
Computer Programming Decision Making (2) Loops Topics The Conditional Execution of C Statements (review) Making a Decision (review) If Statement (review) Switch-case Repeating Statements while loop Examples
More informationProgramming & Data Structure: CS Section - 1/A DO NOT POWER ON THE MACHINE
DS Tutorial: III (CS 11001): Section 1 Dept. of CS&Engg., IIT Kharagpur 1 Tutorial Programming & Data Structure: CS 11001 Section - 1/A DO NOT POWER ON THE MACHINE Department of Computer Science and Engineering
More informationEngineering 12 - Spring, 1998
Engineering 12 - Spring, 1998 1. (15 points) Rewrite the following program so that it uses a while loop in place of the for loop. (Note that a part of the new program is already shown at the bottom of
More informationThe C language. Introductory course #1
The C language Introductory course #1 History of C Born at AT&T Bell Laboratory of USA in 1972. Written by Dennis Ritchie C language was created for designing the UNIX operating system Quickly adopted
More informationUNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING
UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING APS 105 Computer Fundamentals Midterm Examination October 20, 2011 6:15 p.m. 8:00 p.m. (105 minutes) Examiners: J. Anderson, T. Fairgrieve,
More informationEngineering 12 - Spring, 1999
Engineering 12 - Spring, 1999 1. (18 points) A portion of a C program is given below. Fill in the missing code to calculate and display a table of n vs n 3, as shown below: 1 1 2 8 3 27 4 64 5 125 6 216
More informationECE15: Introduction to Computer Programming Using the C Language. Lecture Unit 4: Flow of Control
ECE15: Introduction to Computer Programming Using the C Language Lecture Unit 4: Flow of Control Outline of this Lecture Examples of Statements in C Conditional Statements The if-else Conditional Statement
More informationCSE101-lec#12. Designing Structured Programs Introduction to Functions. Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU
CSE101-lec#12 Designing Structured Programs Introduction to Functions Created By: Amanpreet Kaur & Sanjeev Kumar SME (CSE) LPU Outline Designing structured programs in C: Counter-controlled repetition
More informationprintf("this program adds the value 10 to a given integer number.\n\n");
PA1 Sample Solution Program 1 void add10(int *n); //Prototype int n; printf("this program adds the value 10 to a given integer number.\n\n"); printf("please enter an integer number: "); scanf("%d", &n);
More informationStructured programming
Exercises 4 Version 1.0, 10 October, 2016 Table of Contents 1. Flow control statements if-else............................................. 1 1.1. From lectures...........................................................
More informationStructured programming. Exercises 3
Exercises 3 Table of Contents 1. Reminder from lectures...................................................... 1 1.1. Relational operators..................................................... 1 1.2. Logical
More informationIf Control Construct
If Control Construct A mechanism for deciding whether an action should be taken JPC and JWD 2002 McGraw-Hill, Inc. 1 Boolean Algebra Logical expressions have the one of two values - true or false A rectangle
More information1.3b Type Conversion
1.3b Type Conversion Type Conversion When we write expressions involved data that involves two different data types, such as multiplying an integer and floating point number, we need to perform a type
More information& Technology. Expression? Statement-x. void main() int no; scanf("%d", &no); if(no%2==0) if(no%2!=0) Syllabus for 1. of execution of statements.
statement- Computer Programming and Utilization (CPU) 110003 D) Decision Control Structure (if, if, if e if, switch, ) 1 Explain if with example and draw flowchart. if is used to control the flow of execution
More informationDecisions II. Switch Statement. If else allows a 2 way decision Switch allows for n-way decisions
Switch Statement If else allows a 2 way decision Switch allows for n-way decisions switch(variable){ case val1: statement; case val2: statement; case val3: statement; default: statement; variable must
More informationSlides adopted from T. Ferguson Spring 2016
CSE1311 Introduction to Programming for Science & Engineering Students Mostafa Parchami, Ph.D. Dept. of Comp. Science and Eng., Univ. of Texas at Arlington, USA Slides adopted from T. Ferguson Spring 2016
More informationStructured programming
Exercises 2 Version 1.0, 22 September, 2016 Table of Contents 1. Simple C program structure................................................... 1 2. C Functions..................................................................
More informationLAB 6: While and do-while Loops
Name: Joe Bloggs LAB 6: While and do-while Loops Exercises 1 while loop /* Program name: lab6ex1.c * Purpose : This program demonstrates use of while loop int num = 0; while( num!= -1 ) printf("please
More informationRepetition Structures II
Lecture 9 Repetition Structures II For and do-while loops CptS 121 Summer 2016 Armen Abnousi Types of Control Structures Sequential All programs that we have written so far The statements inside a pair
More informationDecision Making -Branching. Class Incharge: S. Sasirekha
Decision Making -Branching Class Incharge: S. Sasirekha Branching The C language programs presented until now follows a sequential form of execution of statements. Many times it is required to alter the
More informationITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University
ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 08: Control Statements Readings: Chapter 6 Control Statements and Their Types A control
More informationC Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee
C Language Part 2 (Minor modifications by the instructor) 1 Scope Rules A variable declared inside a function is a local variable Each local variable in a function comes into existence when the function
More informationQ1 (15) Q2 (15) Q3 (15) Q4 (15) Total (60)
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Date:.FN / AN Time: 2 hrs Full marks: 60 No. of students: 643 Spring Mid Semester Exams, 2011 Dept: Comp. Sc & Engg. Sub No: CS11001 B.Tech 1 st Year (Core) Sub
More informationUnit 5. Decision Making and Looping. School of Science and Technology INTRODUCTION
INTRODUCTION Decision Making and Looping Unit 5 In the previous lessons we have learned about the programming structure, decision making procedure, how to write statements, as well as different types of
More informationFor questions 4 through 7, select the value assigned to the relevant variable, given the declarations: 3) ) This is not allowed
This homework assignment focuses primarily on some of the basic syntax and semantics of C. The answers to the following questions can be determined by consulting a C language reference and/or writing short
More informationIntroduction to Programming
Introduction to Programming Lecture 6: Making Decisions What We Will Learn Introduction Conditions and Boolean operations if-else statement switch-case statement Conditional expressions 2 What We Will
More informationIntroduction to Programming
Introduction to Programming ( 數 ) Lecture 4 Spring 2005 March 11, 2005 Topics Review of if statement The switch statement Repetition and Loop Statements For-Loop Condition-Loop Reading: Chap. 5.7~ Chap.
More informationMore examples for Control statements
More examples for Control statements C language possesses such decision making capabilities and supports the following statements known as control or decision-making statements. 1. if statement 2. switch
More informationBasic Assignment and Arithmetic Operators
C Programming 1 Basic Assignment and Arithmetic Operators C Programming 2 Assignment Operator = int count ; count = 10 ; The first line declares the variable count. In the second line an assignment operator
More informationVariables in C. CMSC 104, Spring 2014 Christopher S. Marron. (thanks to John Park for slides) Tuesday, February 18, 14
Variables in C CMSC 104, Spring 2014 Christopher S. Marron (thanks to John Park for slides) 1 Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement 2 What
More informationMaterials covered in this lecture are: A. Completing Ch. 2 Objectives: Example of 6 steps (RCMACT) for solving a problem.
60-140-1 Lecture for Thursday, Sept. 18, 2014. *** Dear 60-140-1 class, I am posting this lecture I would have given tomorrow, Thursday, Sept. 18, 2014 so you can read and continue with learning the course
More informationLab Session # 1 Introduction to C Language. ALQUDS University Department of Computer Engineering
2013/2014 Programming Fundamentals for Engineers Lab Lab Session # 1 Introduction to C Language ALQUDS University Department of Computer Engineering Objective: Our objective for today s lab session is
More informationQ1 (15) Q2 (15) Q3 (15) Q4 (15) Total (60)
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Date:.FN / AN Time: 2 hrs Full marks: 60 No. of students: 643 Spring Mid Semester Exams, 2011 Dept: Comp. Sc & Engg. Sub No: CS11001 B.Tech 1 st Year (Core) Sub
More information"'"' .;, b) F or ( c = l ; c <= 10,"' c++ ) X { JJ. ~. Computer Programming I COME Midterm Examination. Fall November 2016
Group B ~. Computer Programming I COME 103 - Midterm Examination B Fall 2016 21 November 2016 1. Identify and correct the errors in each of the following statements. (Note: There may be more than one error.)
More information!"#$% &'($) *+!$ 0!'" 0+'&"$.&0-2$ 10.+3&2),&/3+, %&&/3+, C,-"!.&/+"*0.&('1 :2 %*10% *%7)/ 30'&. 0% /4%./
0!'" 0+'&"$ &0-2$ 10 +3&2),&/3+, #include int main() int i, sum, value; sum = 0; printf("enter ten numbers:\n"); for( i = 0; i < 10; i++ ) scanf("%d", &value); sum = sum + value; printf("their
More informationModule 6: Array in C
1 Table of Content 1. Introduction 2. Basics of array 3. Types of Array 4. Declaring Arrays 5. Initializing an array 6. Processing an array 7. Summary Learning objectives 1. To understand the concept of
More informationSubject: PIC Chapter 2.
02 Decision making 2.1 Decision making and branching if statement (if, if-, -if ladder, nested if-) Switch case statement, break statement. (14M) 2.2 Decision making and looping while, do, do-while statements
More informationChapter 11 Introduction to Programming in C
C: A High-Level Language Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University! Gives
More informationMA 511: Computer Programming Lecture 2: Partha Sarathi Mandal
MA 511: Computer Programming Lecture 2: http://www.iitg.ernet.in/psm/indexing_ma511/y10/index.html Partha Sarathi Mandal psm@iitg.ernet.ac.in Dept. of Mathematics, IIT Guwahati Semester 1, 2010-11 Largest
More informationCSE123 LECTURE 3-1. Program Design and Control Structures Repetitions (Loops) 1-1
CSE123 LECTURE 3-1 Program Design and Control Structures Repetitions (Loops) 1-1 The Essentials of Repetition Loop Group of instructions computer executes repeatedly while some condition remains true Counter-controlled
More informationOnline Judge and C. Roy Chan. January 12, Outline Information Online Judge Introduction to C. CSC2100B Data Structures Tutorial 1
Roy Chan CSC2100B Data Structures Tutorial 1 January 12, 2009 1 / 38 1 Information Your TA team Course Information Assignment 2 Online Judge Writing Your Assignment Program Submitting Your Program Online
More informationC Program. Output. Hi everyone. #include <stdio.h> main () { printf ( Hi everyone\n ); }
C Program Output #include main () { printf ( Hi everyone\n ); Hi everyone #include main () { printf ( Hi everyone\n ); #include and main are Keywords (or Reserved Words) Reserved Words
More informationProgramming Style Guide v1.1
Oregon State University Intro to programming Source Code Style Guide Modified from: OREGON INSTITUTE OF TECHNOLOGY COMPUTER SYSTEMS ENGINEERING TECHNOLOGY Modified by: Joseph Jess Programming Style Guide
More informationNumber Systems, Scalar Types, and Input and Output
Number Systems, Scalar Types, and Input and Output Outline: Binary, Octal, Hexadecimal, and Decimal Numbers Character Set Comments Declaration Data Types and Constants Integral Data Types Floating-Point
More informationControl Structure: Loop
Control Structure: Loop Knowledge: Understand the various concepts of loop control structure Skill: Be able to develop a program involving loop control structure 1 Loop Structure Condition is tested first
More informationDECISION CONTROL AND LOOPING STATEMENTS
DECISION CONTROL AND LOOPING STATEMENTS DECISION CONTROL STATEMENTS Decision control statements are used to alter the flow of a sequence of instructions. These statements help to jump from one part of
More informationAssignment 6. Q1. Create a database of students using structures, where in each entry of the database will have the following fields:
Assignment 6 Q1. Create a database of students using structures, where in each entry of the database will have the following fields: 1. a name, which is a string with at most 128 characters 2. their marks
More informationChapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University C: A High-Level Language! Gives
More informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 04 Programs with IO and Loop We will now discuss the module 2,
More informationWhat we have learned so far
What we have learned so far Straight forward statements Conditional statements (branching) Repeated statements (loop) Arrays One variable many data Problem: Read 10 numbers from the keyboard and store
More informationModule 4: Decision-making and forming loops
1 Module 4: Decision-making and forming loops 1. Introduction 2. Decision making 2.1. Simple if statement 2.2. The if else Statement 2.3. Nested if Statement 3. The switch case 4. Forming loops 4.1. The
More informationPROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE
PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE 1. Write a C program to perform addition, subtraction, multiplication and division of two numbers. # include # include int a, b,sum,
More informationFundamentals of Programming. Lecture 14 Hamed Rasifard
Fundamentals of Programming Lecture 14 Hamed Rasifard 1 Outline Two-Dimensional Array Passing Two-Dimensional Arrays to a Function Arrays of Strings Multidimensional Arrays Pointers 2 Two-Dimensional Array
More informationChapter 6. Loops. Iteration Statements. C s iteration statements are used to set up loops.
Chapter 6 Loops 1 Iteration Statements C s iteration statements are used to set up loops. A loop is a statement whose job is to repeatedly execute some other statement (the loop body). In C, every loop
More informationBSM540 Basics of C Language
BSM540 Basics of C Language Chapter 9: Functions I Prof. Manar Mohaisen Department of EEC Engineering Review of the Precedent Lecture Introduce the switch and goto statements Introduce the arrays in C
More informationEECE.2160: ECE Application Programming Fall 2017
EECE.2160: ECE Application Programming Fall 2017 1. (46 points) C input/output; operators Exam 1 Solution a. (13 points) Show the output of the short program below exactly as it will appear on the screen.
More informationProgramming for Electrical and Computer Engineers. Loops
Programming for Electrical and Computer Engineers Loops Dr. D. J. Jackson Lecture 6-1 Iteration Statements C s iteration statements are used to set up loops. A loop is a statement whose job is to repeatedly
More informationLecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan
Lecture 08-1 Programming in C++ PART 1 By Assistant Professor Dr. Ali Kattan 1 The Conditional Operator The conditional operator is similar to the if..else statement but has a shorter format. This is useful
More informationChapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified by Chris Wilcox, Yashwant Malaiya Colorado State University C: A High-Level Language
More informationC Programming
204216 -- C Programming Chapter 3 Processing and Interactive Input Adapted/Assembled for 204216 by Areerat Trongratsameethong A First Book of ANSI C, Fourth Edition Objectives Assignment Mathematical Library
More informationC Fundamentals & Formatted Input/Output. adopted from KNK C Programming : A Modern Approach
C Fundamentals & Formatted Input/Output adopted from KNK C Programming : A Modern Approach Program: Printing a Pun pun.c The file name doesn t matter, but the.c extension is often required. for example:
More informationUIC. C Programming Primer. Bharathidasan University
C Programming Primer UIC C Programming Primer Bharathidasan University Contents Getting Started 02 Basic Concepts. 02 Variables, Data types and Constants...03 Control Statements and Loops 05 Expressions
More informationBil 104 Intiroduction To Scientific And Engineering Computing. Lecture 7
Strings and Clases BIL104E: Introduction to Scientific and Engineering Computing Lecture 7 Manipulating Strings Scope and Storage Classes in C Strings Declaring a string The length of a string Copying
More informationUNIT 4. CONTROL FLOW. Programming Year Grade in Industrial Technology Engineering. Paula de Toledo. David Griol
Programming Unit 4. Control flow Haga clic para modificar el estilo de texto del patrón UNIT 4. CONTROL FLOW Programming Year 2017-2018 Grade in Industrial Technology Engineering Paula de Toledo. David
More informationControl Flow, Functions and Basic Linkage
Control Flow, Functions and Basic Linkage MATH 5061: Fundamentals of Computer Programming for Scientists and Engineers Dr. Richard Berger richard.berger@temple.edu Department of Mathematics Temple University
More informationWorksheet 4 Basic Input functions and Mathematical Operators
Name: Student ID: Date: Worksheet 4 Basic Input functions and Mathematical Operators Objectives After completing this worksheet, you should be able to Use an input function in C Declare variables with
More informationStatements. Control Flow Statements. Relational Operators. Logical Expressions. Relational Operators. Relational Operators 1/30/14
Statements Control Flow Statements Based on slides from K. N. King Bryn Mawr College CS246 Programming Paradigm So far, we ve used return statements and expression statements. Most of C s remaining statements
More informationA brief intro to pointers for the purposes of passing reference parameters
A brief intro to pointers for the purposes of passing reference parameters With respect to functions, we have only talked about pass by value parameters. Today we will discuss pass by reference parameters.
More informationLecture 10: Recursive Functions. Computer System and programming in C 1
Lecture 10: Recursive Functions Computer System and programming in C 1 Outline Introducing Recursive Functions Format of recursive Functions Tracing Recursive Functions Examples Tracing using Recursive
More informationProgram Control Structures
Program Control Structures Michael Griffiths Corporate Information and Computing Services The University of Sheffield Email m.griffiths@sheffield.ac.uk Control Sequence Structures Selection Structures
More informationFunctions. Arash Rafiey. September 26, 2017
September 26, 2017 are the basic building blocks of a C program. are the basic building blocks of a C program. A function can be defined as a set of instructions to perform a specific task. are the basic
More informationChapter 11 Introduction to Programming in C
C: A High-Level Language Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University Gives
More informationCOL 100 Introduction to Programming- MINOR 1 IIT Jammu
COL 100 Introduction to Programming- MINOR 1 IIT Jammu Time 1 Hr Max Marks 40 03.09.2016 NOTE: THERE 4 QUESTIONS IN ALL NOTE: 1. Do all the questions. 2. Write your name, entry number and group in all
More informationSlide Set 1. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary
Slide Set 1 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2016 ENCM 339 Fall 2016 Slide Set 1 slide 2/43
More informationIPC144 - Introduction to Strings. array of characters is an array, each element of which has a character data type.
IPC144 - Introduction to Strings Agenda: 1 Review/Questions 2 Array of characters 3 Character Strings 4 Try it! 5 Homework Array of Characters array of characters is an array, each element of which has
More informationFlow of Control. Selection. if statement. True and False in C False is represented by any zero value. switch
Flow of Control True and False in C Conditional Execution Iteration Nested Code(Nested-ifs, Nested-loops) Jumps 1 True and False in C False is represented by any zero value The int expression having the
More informationRecursion and Induction: Haskell; Primitive Data Types; Writing Function Definitions
Recursion and Induction: Haskell; Primitive Data Types; Writing Function Definitions Greg Plaxton Theory in Programming Practice, Spring 2005 Department of Computer Science University of Texas at Austin
More informationint marks[10]; // fixed size and fixed address No change in Memory address.
Dynamic Memory Allocation : Used When we want to allocate memory during run time. int marks[10]; // fixed size and fixed address No change in Memory address. // fixed size. ( no change in size possible
More informationName Roll No. Section
Indian Institute of Technology, Kharagpur Computer Science and Engineering Department Class Test I, Autumn 2012-13 Programming & Data Structure (CS 11002) Full marks: 30 Feb 7, 2013 Time: 60 mins. Name
More informationChapter 13 Control Structures
Chapter 13 Control Structures Control Structures Conditional making a decision about which code to execute, based on evaluated expression if if-else switch Iteration executing code multiple times, ending
More informationP.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS)
FACULTY: Ms. Saritha P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS) SUBJECT / CODE: Programming in C and Data Structures- 15PCD13 What is token?
More informationConcept of algorithms Understand and use three tools to represent algorithms: Flowchart Pseudocode Programs
Morteza Noferesti Concept of algorithms Understand and use three tools to represent algorithms: Flowchart Pseudocode Programs We want to solve a real problem by computers Take average, Sort, Painting,
More informationPESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities
PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Basic Science and Humanities Continuous Internal Evaluation Test 2 Date: 0-10- 2017 Marks: 0 Subject &
More informationProgramming and Data Structures Mid-Semester - Solutions to Sample Questions Dept. of Computer Science and Engg. IIT Kharagpur Spring
Programming and Data Structures Mid-Semester - s to Sample Questions Dept. of Computer Science and Engg. IIT Kharagpur Spring 2015-16 February 15, 2016 1. Tick the correct options. (a) Consider the following
More informationfor Loop Lesson 2 Outline
Outline 1. Outline 2. for Loop Application 3. Factorial 4. Factorial Program #1 5. Factorial Program #2 6. for Loop With Implicit Increment 7. for Loop With Explicit Increment #1 8. for Loop With Explicit
More informationLecture 6. Statements
Lecture 6 Statements 1 Statements This chapter introduces the various forms of C++ statements for composing programs You will learn about Expressions Composed instructions Decision instructions Loop instructions
More informationCOMP 2001/2401 Test #1 [out of 80 marks]
COMP 2001/2401 Test #1 [out of 80 marks] Duration: 90 minutes Authorized Memoranda: NONE Note: for all questions, you must show your work! Name: Student#: 1. What exact shell command would you use to:
More informationYacoub Sabatin Muntaser Abulafi Omar Qaraeen
Programming Fundamentals for Engineers - 0702113 6. Arrays Yacoub Sabatin Muntaser Abulafi Omar Qaraeen 1 One-Dimensional Arrays There are times when we need to store a complete list of numbers or other
More informationChapter 3: Arrays and More C Functionality
Chapter 3: Arrays and More C Functionality Objectives: (a) Describe how an array is stored in memory. (b) Define a string, and describe how strings are stored. (c) Describe the implications of reading
More informationBranching is deciding what actions to take and Looping is deciding how many times to take a certain action.
3.0 Control Statements in C Statements The statements of a C program control the flow of program execution. A statement is a command given to the computer that instructs the computer to take a specific
More informationConditional Expressions
Conditional Expressions Boolean Expressions: An expression that evaluates to either TRUE or FALSE. The most common types of boolean expressions are those that use relational operators. The general syntax
More informationProgramming Language A
Programming Language A Takako Nemoto (JAIST) 30 October Takako Nemoto (JAIST) 30 October 1 / 29 From Homework 3 Homework 3 1 Write a program to convert the input Celsius degree temperature into Fahrenheight
More informationThere are algorithms, however, that need to execute statements in some other kind of ordering depending on certain conditions.
Introduction In the programs that we have dealt with so far, all statements inside the main function were executed in sequence as they appeared, one after the other. This type of sequencing is adequate
More information2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants
Data types, variables, constants Outline.1 Introduction. Text.3 Memory Concepts.4 Naming Convention of Variables.5 Arithmetic in C.6 Type Conversion Definition: Computer Program A Computer program is a
More information