Subject: PIC Chapter 2.

Size: px
Start display at page:

Download "Subject: PIC Chapter 2."

Transcription

1 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 for loop, continue statement (14M) Marks 28 CO204.3 Implement the C program using control structure 2.1 The if Statement The general form of if statement looks like this if ( test condition ) Statements; The keyword if tells the compiler that what follows is a decision control instruction. The condition following the keyword if is always enclosed within a pair of parentheses (). If the condition is true, then the statements are executed. If the condition is not true then the statement is not executed. E.g. if ( x = = 10) y = x+ 5; Here, if the value of x is equal to integer constant 10 then statements within curly brackets i.e. y = x+5 will be executed otherwise skipped. e.g. main( ) int x = 10, y; if (x = = 10) y = x+ 5; printf( Value of y = %d \n, y); printf( Hello to the World of C ); Output: Value of y = 15 Hello to the World of C E.g. main( ) 1

2 int x = 5, y; if (x = = 10) y = x+ 5; printf( Value of y = %d \n, y); printf( Hello to the World of C ); Output: Hello to the World of C The if- Statement General form if (test condition) // if block starts Statements_1; Statements_2; // if block ends // block starts Statements_3; Statements_4; // block ends Here, based on condition is true or false if block or block will be executed. If condition is true then if block will be executed i.e. statements 1 and 2 will be executed. If condition is false then block will be executed i.e. statements 3 and 4 will be executed. Only one block, either if block or block, will be executed. E.g. main( ) int num1 = 10, num2 = 30; if ( num1 > num2) printf( Number 1 Is Greater ); printf( Number 2 Greater ); Here, condition checks which number is greater. Output: Number 2 Greater As the condition is false statement within block is executed. I.e. Number 2 is greater. 2

3 Nested if- We can write an entire if- construct within the body of the if statement and within the body of an statement. This is called nesting of ifs. General form if (test condition 1) if(test condition 2) Statement 1; Statement 2; Statement 3; Statement 4; Statement 5; Statement 6; Here, condition 1 is checked first, if it returns true then inner if condition 2 is checked. If condition 2 is true then statements 1 and 2 are executed. If condition 2 is false then statements 3 and 4 are executed. If condition 1 is false then block will be executed i.e. statements 5 and 6 will get executed. if ladder Used when multipath decision is involved General form if ( condition 1) Statement_1; if (condition 2) Statement_2; if (condition 3) Statement_3; 3

4 if (condition 4) Statement_4; Statement_5; Conditions are evaluated from top to bottom still true condition is found. As soon as true condition is met, block of statements associated with it is executed and rest of the if ladder is skipped. When all the conditions become false then the final block is executed. Programs: 1. Program to find biggest number among 3 numbers using if ladder /* Program to find biggest number among 3 numbers */ int no1, no2, no3; printf("enter 3 numbers : "); scanf("%d%d%d", &no1,&no2,&no3); if( no1 > no2 && no1 > no3) printf("biggest Number is %d", no1); if( no2 > no1 && no2 > no3) printf("biggest Number is %d", no2); if( no3 > no2 && no3 > no1) printf("biggest Number is %d", no3); printf(" All numbers are equal"); 2.Program to find biggest number among 3 numbers using if int no1, no2, no3; printf("enter 3 numbers : "); scanf("%d%d%d", &no1,&no2,&no3); if( no1 > no2 && no1 > no3) 4

5 printf("biggest Number is %d", no1); if( no2 > no1 && no2 > no3) printf("biggest Number is %d", no2); printf("biggest Number is %d", no3); 3.Program to accept marks of 5 subjects. Calculate total and average. Based on average determine the class obtained. int m1, m2, m3, m4, m5, total; float per; printf("enter marks of subject "); scanf("%d %d %d %d %d", &m1, &m2, &m3, &m4, &m5); total = m1+m2+m3+m4+m5; per = (float) total/5; printf("\n Percentage is %f", per); if( per >= 75) printf("\nyou got Distinction "); if ( per >= 60) printf("\nyou got First Class "); if ( per >= 50) printf("\nyou got Second Class "); if ( per >= 40) printf("\nyou got Pass Class "); printf("\nsorry you failed"); 5

6 int m1, m2, m3, m4, m5, total; float avg; printf("enter marks of subject "); scanf("%d %d %d %d %d", &m1, &m2, &m3, &m4, &m5); total = m1+m2+m3+m4+m5; avg = (float) total/5; printf("\n Avg is %f", avg); if( avg >= 75) printf("\nyou got Distinction "); if ( avg >= 60) printf("\nyou got First Class "); if ( avg >= 50) printf("\nyou got Second Class "); if ( avg >= 40) printf("\nyou got Pass Class "); printf("\nsorry you failed"); 5. Program to find biggest between two numbers. 6

7 int no1, no2; //To clear the screen printf("enter two numbers "); scanf("%d%d", &no1,&no2); if (no1 > no2) printf("\nbigger number is %d", no1); printf("\nbigger number is %d", no2); 6. Program to find number is even or odd int num; printf("enter a number "); scanf("%d", &num); if(num % 2 == 0) printf("\n Entered number %d is Even",num); printf("\n Entered number %d is Odd",num); 7. Program to find number is positive or negative int num; printf("enter the number"); scanf("%d", &num); if(num > 0) printf("\n %d is positive number", num); printf("\n %d is negative number", num); 7

8 8. Find entered character is vowel or not char ch; printf("enter a character "); scanf("%c", &ch); if( ch == 'a' ch == 'e' ch == 'i' ch == 'o' ch == 'u') printf("entered character %c is a Vowel", ch); printf("entered character %c is not a Vowel", ch); 9. Program to find smallest number among 3 numbers int no1, no2, no3; printf("enter three numbers "); scanf("%d%d%d", &no1,&no2,&no3); if ( no1 < no2 && no1 < no3) printf("\nsmallest number is %d ", no1); if ( no2 < no1 && no2 < no3) printf("\nsmallest number is %d ", no2); printf("\nsmallest number is %d ", no3); 10. Program to find whether entered year is Leap year */ 8

9 int year; printf("enter year"); scanf("%d", &year); if ((year % 4 == 0 && year % 100!= 0) year % 400 == 0) printf("enter year %d is Leap Year", year); printf("enter year %d is not Leap year", year); switch case statement The control statement that allows us to make a decision from the number of choices. General form switch (expression ) case value_1 : Block of statements; case value_2 : Block of statements; case value_3 : Block of statements; case value_4 : Block of statements; default : Block of statements ; First, the expression following the keyword switch is evaluated. The value it gives is then matched, one by one, against the values that follow the case statements. When a match is found, the program executes the statements following that case, and exits from switch case. If no match is found with any of the case statements, only the statements following the default are executed. E.g. main( ) int i = 2 ; switch ( i ) 9

10 case 1 : printf ( "I am in case 1 \n" ) ; break ; case 2 : printf ( "I am in case 2 \n" ) ; break ; case 3 : printf ( "I am in case 3 \n" ) ; break ; default : printf ( "I am in default \n" ) ; The output of this program would be: I am in case 2 Program to find entered character is vowel or not using switch case char ch; printf("enter a character "); scanf("%c", &ch); switch(ch) case 'a': case 'e': case 'i': case 'o': case 'u': printf("\nentered character %c is vowel ", ch); default : printf("\nentered character %c is not vowel ", ch); Menu driven program to perform 1.Addition 2.Substraction 3.Division 4.Multiplication 10

11 int x, y, z, opt; printf(" Enter two numbers "); scanf("%d%d", &x,&y); printf("\n 1. Addition"); printf("\n 2. Substraction"); printf("\n 3. Multiplication"); printf("\n 4. Division"); printf("\nenter Your Option"); scanf("%d",&opt); switch(opt) case 1 : z = x+y; printf("\naddition is %d", z); case 2 : z = x - y; printf("\nsubstraction is %d",z); case 3 : z = x * y; printf("\nmultiplication is %d",z); case 4 : z = x / y; printf("\ndivision is %d",z); default : printf("invalid choice"); Q. Write a menu driven program for following options 1. Find a number even or odd 2. Sum of two numbers int opt, num, x,y,z; printf("\n 1. Even Or Odd"); printf("\n 2. Sum of two Numbers"); printf("\nenter Your Option"); scanf("%d",&opt); switch(opt) 11

12 case 1 : printf("enter a number "); scanf("%d", &num); if(num % 2 == 0) printf("\n Entered number %d is Even",num); printf("\n Entered number %d is Odd",num); case 2 : printf("enter two numbers "); scanf("%d%d", &x, &y); z = x + y; printf("\nsum is %d",z); default : printf("invalid choice"); Loops (iteration) The versatility of the computer lies in its ability to perform a set of instructions repeatedly. This involves repeating some portion of the program either a specified number of times or until a particular condition is being satisfied. This repetitive operation is done through a loop control instruction. There are three methods by way of which we can repeat a part of a program. They are: (a) Using a for statement (b) Using a while statement (c) Using a do-while statement The while Loop The general form of while is as shown below: initialise loop counter ; while ( test condition ) Statements; // block of while loop increment / decrement of loop counter ; The statements within the while loop would keep on getting executed till the condition being tested remains true. When the condition becomes false, the control passes to the first statement that follows the body of the while loop. As a rule the while must test a condition that will eventually become false, otherwise the loop would be executed forever indefinitely. 12

13 Q. Program to find Factorial of a number using while loop int i = 1, fact = 1, num; printf("enter a number to find Factorial "); scanf("%d", &num); while( i <= num ) fact = fact * i; i++; printf ("\n Factorial of entered number %d is %d ", num, fact); Q. Fibonacci series using while loop int i=1, fab, s1 = 0,s2 = 1, num; printf("enter a number"); scanf("%d", &num); printf(" 0 \n 1 "); while( i <= num-2) fab = s1 + s2; printf("\n %d ", fab); s1 = s2; s2 = fab; i++; Q. Program find number is prime or not using while loop int i=2, num; printf("enter a number to find prime or not "); scanf("%d", &num); while( i < num ) if(num % i == 0) printf("enter number %d is not prime", num); 13

14 i++; if ( num == i ) printf("enter number %d is prime", num); Q. Program to print a number in reverse order int num,rem; printf("enter the number"); scanf("%d",&num); while( num!= 0 ) rem = num % 10; printf("%d",rem); num = num / 10; Q. Program to calculate sum of digits of a number int num,rem, sum = 0; printf("enter the number"); scanf("%d",&num); while( num!= 0 ) rem = num % 10; sum = sum + rem; num = num / 10; printf("sum of digits of entered number is %d",sum); Q. Program to print first 10 odd numbers using while loop int i = 1; while(i<= 20) if(i % 2!= 0) 14

15 i++; printf("\n%d",i); Q.Program to print first 10 even numbers using while loop int i = 1; while(i<= 20) if(i % 2 == 0) printf("\n%d",i); i++; Q.Program to find sum of series n int i=1, sum = 0, num; printf("enter the Number "); scanf("%d",&num); while(i<=num) sum = sum + i; i++; printf("sum of series is %d ",sum); The do-while Loop do Block of statements; while (test condition); the do-while tests the condition after having executed the statements within the loop. do-while would execute its statements at least once, even if the condition fails for the first time. 15

16 E.g. main( ) do printf ( "Hello there \n") ; while ( 4 < 1 ) ; In this program the printf( ) would be executed once, since first the body of the loop is executed and then the condition is tested. The for Loop The for allows us to specify three things about a loop in a single line: (a) Setting a loop counter to an initial value. (b) Testing the loop counter to determine whether its value has reached the number of repetitions desired. (c) Increasing the value of loop counter each time the program segment within the loop has been executed. The general form of for statement is as under: for ( initialize counter ; test condition ; increment/decrement counter ) Statements://Block of for loop; When the for statement is executed for the first time, the value of counter is set to an initial value. Then the condition is tested. If condition is true then the body of the loop is executed for the first time. Upon reaching the closing brace of for, the value of counter gets incremented. Again the condition is checked and if result is true then statements within loop of body is executed. Body of loop is executed till condition is true. When condition gets false the control exits from the loop and is transferred to the statement (if any) immediately after the body of for loop. 1. Program to find first 10 even numbers using for loop int i; for ( i = 2 ; i <= 20 ; i = i + 2) printf("%d \n", i); 16

17 2. Fabonacci series using for loop int i, fab, s1 = 0,s2 = 1, num; printf("enter a number"); scanf("%d", &num); printf(" 0 \n 1 "); for ( i = 1; i <= num-2; i++) fab = s1 + s2; printf("\n %d ", fab); s1 = s2; s2 = fab; 3. Factorial of a number using for loop int i, fact = 1, num; printf("enter a number to find Factorial "); scanf("%d", &num); for ( i = 1; i <= num ; i++) fact = fact * i; printf ("\n Factorial of entered number %d is %d ", num, fact); 4. Program find number is prime or not using for loop int i, num; printf("enter a number to find prime or not "); scanf("%d", &num); for ( i = 2 ; i < num ; i++) if(num % i == 0) printf("enter number %d is not prime", num); 17

18 if ( num == i ) printf("enter number %d is prime", num); 5. Sum of series n using for loop int i, sum = 0, num; printf("enter a number "); scanf("%d", &num); for ( i = 1; i <= num ; i++) sum = sum + i; printf ("\n Sum of entered series %d is %d ", num, sum); 6. Write a program using loop to print following : * * * * * * int i,j; for(i=1; i <= 5 ; i++) for(j = 1; j <=i; j++) printf(" * \t"); printf("\n"); Assignment 4. Q.1. Explain break and continue statement with example. The break Statement When break is encountered inside any loop, control automatically passes to the first statement after the loop. A break is usually associated with an if. E.g. 18

19 main( ) int i = 1 ; while ( i <= 10 ) if ( i == 5 ) break ; printf ( "%d \n", i ) ; i++; printf( Back in Main function ); Output: Back in Main function In this program when i equals 5, break takes the control outside the while loop to statement next to end of while loop. The continue Statement When continue is encountered inside any loop, control automatically passes to the beginning of the loop. A continue is usually associated with an if. E.g. int i; for(i=1; i<=5; i++) if(i==2) continue; printf("%d\n",i); printf("in main function"); The output of the above program would be In main function 19

20 Here, when the value of i equals that of 2, the continue statement takes the control to the beginning of the for loop. Q. 2. Write syntax of if- statement. Q. 3. State any four control statement. Q. 4. State any decision making statements. Q. 5. Explain -if ladder with execution. Q. 6.Explain working of do-while loop with syntax and example. Q. 7.State difference between if and switch statement. if statement 1. The general form of if statement looks like this if ( test condition ) Statements; switch statement 1. switch (expression ) case value_1 : Block of statements; case value_2 : Block of statements; default : Block of statements ; 2. Only one condition can be checked to execute the 2. Multiple constant value can checked to execute block or to skip. statements. 3. Can test relational or logical expression. 3. Can test only for equality. 5. Same condition can be repeated number of times. 4.no two cases can have same constant in a switch Q. 8. Explain switch-case statement with syntax and small example. Q. 9. State use of break and continue statement. Q. 10. State and explain if, if-, nested if-, for loop, while loop with an example and flow chart. Q. 11. Difference between while and do-while loops. Q. 11. Programs 1. Write a program to swap the values of two integer numbers. 2. Write a program to find out largest number between 3 integer numbers. 3. Write a program to accept a character from user and find whether character is vowel or not. 4. Write a program to accept a character from user and find whether character is vowel or not, using switch case. 5. Write a program to display following menu and do operation as per user choice, using switch case: 1. Addition 2. Subtraction 3. Multiplication 4. Division 6. Write a program to display the sum of all even numbers from 1 to n. Accept n from user. 7. Write a program to calculate sum of digits of five digit integer number. 8. Write a program to generate a Fibonacci series of first 10 numbers. 9. Write a program to print factorial of a number. 10. Write a program to print whether number is prime or not. 11. Write a program using loop to print following : * * * * * * 12. Write a program to display odd numbers from 1 to n. where n is accepted from user. 13. Write a program to generate a Fibonacci series using while loop. 14. Write a program to print first 10 odd numbers using while loop. 20

21 15. Write a program to calculate sum of series n using while loop. 16. If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred. 17. Any year is input through the keyboard. Write a program to determine whether the year is a leap year or not. 21

Branching is deciding what actions to take and Looping is deciding how many times to take a certain action.

Branching 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 information

Loops / Repetition Statements

Loops / Repetition Statements Loops / Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops C has three kinds of repetition statements: the while loop the for

More information

DECISION CONTROL AND LOOPING STATEMENTS

DECISION 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 information

Loops / Repetition Statements

Loops / Repetition Statements Loops / Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops C has three kinds of repetition statements: the while loop the for

More information

Introduction. C provides two styles of flow control:

Introduction. C provides two styles of flow control: Introduction C provides two styles of flow control: Branching Looping Branching is deciding what actions to take and looping is deciding how many times to take a certain action. Branching constructs: if

More information

Unit 5. Decision Making and Looping. School of Science and Technology INTRODUCTION

Unit 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 information

Module 4: Decision-making and forming loops

Module 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 information

3 The L oop Control Structure

3 The L oop Control Structure 3 The L oop Control Structure Loops The while Loop Tips and Traps More Operators The for Loop Nesting of Loops Multiple Initialisations in the for Loop The Odd Loop The break Statement The continue Statement

More information

SELECTION STATEMENTS:

SELECTION STATEMENTS: UNIT-2 STATEMENTS A statement is a part of your program that can be executed. That is, a statement specifies an action. Statements generally contain expressions and end with a semicolon. Statements that

More information

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

ITC213: 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 information

ECE15: 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 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 information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate

More information

MODULE 2: Branching and Looping

MODULE 2: Branching and Looping MODULE 2: Branching and Looping I. Statements in C are of following types: 1. Simple statements: Statements that ends with semicolon 2. Compound statements: are also called as block. Statements written

More information

Unit 3 Decision making, Looping and Arrays

Unit 3 Decision making, Looping and Arrays Unit 3 Decision making, Looping and Arrays Decision Making During programming, we have a number of situations where we may have to change the order of execution of statements based on certain conditions.

More information

REPETITION CONTROL STRUCTURE LOGO

REPETITION CONTROL STRUCTURE LOGO CSC 128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING REPETITION CONTROL STRUCTURE 1 Contents 1 Introduction 2 for loop 3 while loop 4 do while loop 2 Introduction It is used when a statement or a block of

More information

All copyrights reserved - KV NAD, Aluva. Dinesh Kumar Ram PGT(CS) KV NAD Aluva

All copyrights reserved - KV NAD, Aluva. Dinesh Kumar Ram PGT(CS) KV NAD Aluva All copyrights reserved - KV NAD, Aluva Dinesh Kumar Ram PGT(CS) KV NAD Aluva Overview Looping Introduction While loops Syntax Examples Points to Observe Infinite Loops Examples using while loops do..

More information

Introduction to Computing Lecture 07: Repetition and Loop Statements (Part II)

Introduction 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 information

Computers Programming Course 7. Iulian Năstac

Computers Programming Course 7. Iulian Năstac Computers Programming Course 7 Iulian Năstac Recap from previous course Operators in C Programming languages typically support a set of operators, which differ in the calling of syntax and/or the argument

More information

Prepared by: Shraddha Modi

Prepared by: Shraddha Modi Prepared by: Shraddha Modi Introduction In looping, a sequence of statements are executed until some conditions for termination of the loop are satisfied. A program loop consist of two segments Body of

More information

Questions Bank. 14) State any four advantages of using flow-chart

Questions Bank. 14) State any four advantages of using flow-chart Questions Bank Sub:PIC(22228) Course Code:-EJ-2I ----------------------------------------------------------------------------------------------- Chapter:-1 (Overview of C Programming)(10 Marks) 1) State

More information

공학프로그래밍언어 (PROGRAMMING LANGUAGE FOR ENGINEERS) -CONTROL FLOW : LOOP- SPRING 2015, SEON-JU AHN, CNU EE

공학프로그래밍언어 (PROGRAMMING LANGUAGE FOR ENGINEERS) -CONTROL FLOW : LOOP- SPRING 2015, SEON-JU AHN, CNU EE 공학프로그래밍언어 (PROGRAMMING LANGUAGE FOR ENGINEERS) -CONTROL FLOW : LOOP- SPRING 2015, SEON-JU AHN, CNU EE LOOPS WHILE AND FOR while syntax while (expression) statement The expression is evaluated. If it is

More information

Loops / Repetition Statements. There are three loop constructs in C. Example 2: Grade of several students. Example 1: Fixing Bad Keyboard Input

Loops / Repetition Statements. There are three loop constructs in C. Example 2: Grade of several students. Example 1: Fixing Bad Keyboard Input Loops / Repetition Statements Repetition s allow us to execute a multiple times Often they are referred to as loops C has three kinds of repetition s: the while loop the for loop the do loop The programmer

More information

Flow of Control. Selection. if statement. True and False in C False is represented by any zero value. switch

Flow 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 information

Decision Making -Branching. Class Incharge: S. Sasirekha

Decision 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 information

Decision Making and Branching

Decision Making and Branching INTRODUCTION Decision Making and Branching Unit 4 In the previous lessons we have learned about the programming structure, data types, declaration of variables, tokens, constants, keywords and operators

More information

PROGRAMMING IN C LAB MANUAL FOR DIPLOMA IN ECE/EEE

PROGRAMMING 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 information

Java Programming: Guided Learning with Early Objects Chapter 5 Control Structures II: Repetition

Java Programming: Guided Learning with Early Objects Chapter 5 Control Structures II: Repetition Java Programming: Guided Learning with Early Objects Chapter 5 Control Structures II: Repetition Learn about repetition (looping) control structures Explore how to construct and use: o Counter-controlled

More information

WAP 10. WAP 11. WAP 12. WAP 13. WAP 14. WAP 15. WAP 16. WAP 1. : 17. WAP 18. WAP 19. WAP 20. WAP 21. WAP 22. WAP 23. WAP & 24. WAP

WAP 10. WAP 11. WAP 12. WAP 13. WAP 14. WAP 15. WAP 16. WAP 1. : 17. WAP 18. WAP 19. WAP 20. WAP 21. WAP 22. WAP 23. WAP & 24. WAP Contents 1. WAP to accept the value from the user and exchange the values.... 2 2. WAP to check whether the number is even or odd.... 2 3. WAP to Check Odd or Even Using Conditional Operator... 3 4. WAP

More information

UIC. C Programming Primer. Bharathidasan University

UIC. 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 information

'C' Programming Language

'C' Programming Language F.Y. Diploma : Sem. II [DE/EJ/ET/EN/EX] 'C' Programming Language Time: 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1(a) Define pointer. Write syntax

More information

Java Programming: Guided Learning with Early Objects Chapter 5 Control Structures II: Repetition

Java Programming: Guided Learning with Early Objects Chapter 5 Control Structures II: Repetition Java Programming: Guided Learning with Early Objects Chapter 5 Control Structures II: Repetition Learn about repetition (looping) control structures Explore how to construct and use: o Counter-controlled

More information

(Refer Slide Time: 00:26)

(Refer Slide Time: 00:26) Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute Technology, Madras Module 07 Lecture 07 Contents Repetitive statements

More information

A control structure refers to the way in which the Programmer specifies the order of executing the statements

A control structure refers to the way in which the Programmer specifies the order of executing the statements Control Structures A control structure refers to the way in which the Programmer specifies the order of executing the statements The following approaches can be chosen depending on the problem statement:

More information

Repetition Structures II

Repetition 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 information

Dr. R. Z. Khan, Associate Professor, Department of Computer Science

Dr. R. Z. Khan, Associate Professor, Department of Computer Science ALIGARH MUSLIM UNIVERSITY Department of Computer Science Course: CSM-102: Programming & Problem Solving Using C Academic Session 2015-2016 UNIT-2: Handout-3 Topic: Control Structures (Selection & Repetition)

More information

Syntax of for loop is as follows: for (inite; terme; updatee) { block of statements executed if terme is true;

Syntax of for loop is as follows: for (inite; terme; updatee) { block of statements executed if terme is true; Birla Institute of Technology & Science, Pilani Computer Programming (CSF111) Lab-5 ---------------------------------------------------------------------------------------------------------------------------------------------

More information

BCA-105 C Language What is C? History of C

BCA-105 C Language What is C? History of C C Language What is C? C is a programming language developed at AT & T s Bell Laboratories of USA in 1972. It was designed and written by a man named Dennis Ritchie. C seems so popular is because it is

More information

Chapter 2. Introduction to C language. Together Towards A Green Environment

Chapter 2. Introduction to C language. Together Towards A Green Environment Chapter 2 Introduction to C language Aim Aim of this chapter is to provide the fundamentals for basic program construction using C. Objectives To understand the basic information such as keywords, character

More information

Flow Control. CSC215 Lecture

Flow Control. CSC215 Lecture Flow Control CSC215 Lecture Outline Blocks and compound statements Conditional statements if - statement if-else - statement switch - statement? : opertator Nested conditional statements Repetitive statements

More information

PESIT 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 INTERNAL ASSESSMENT TEST 1 SOLUTION PART 1 1 a Define algorithm. Write an algorithm to find sum and average of three numbers. 4 An Algorithm is a step by step procedure to solve a given problem in finite

More information

P.E.S. INSTITUTE OF TECHNOLOGY BANGALORE SOUTH CAMPUS 1 ST INTERNAL ASSESMENT TEST (SCEME AND SOLUTIONS)

P.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 information

COMPUTER PROGRAMMING LOOPS

COMPUTER PROGRAMMING LOOPS COMPUTER PROGRAMMING LOOPS http://www.tutorialspoint.com/computer_programming/computer_programming_loops.htm Copyright tutorialspoint.com Let's consider a situation when you want to write five times. Here

More information

Decision Making and Loops

Decision Making and Loops Decision Making and Loops Goals of this section Continue looking at decision structures - switch control structures -if-else-if control structures Introduce looping -while loop -do-while loop -simple for

More information

Chapter 6. Loops. Iteration Statements. C s iteration statements are used to set up loops.

Chapter 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 information

Chapter 4: Control structures. Repetition

Chapter 4: Control structures. Repetition Chapter 4: Control structures Repetition Loop Statements After reading and studying this Section, student should be able to Implement repetition control in a program using while statements. Implement repetition

More information

1. Basics 1. Write a program to add any two-given integer. Algorithm Code 2. Write a program to calculate the volume of a given sphere Formula Code

1. Basics 1. Write a program to add any two-given integer. Algorithm Code  2. Write a program to calculate the volume of a given sphere Formula Code 1. Basics 1. Write a program to add any two-given integer. Algorithm - 1. Start 2. Prompt user for two integer values 3. Accept the two values a & b 4. Calculate c = a + b 5. Display c 6. Stop int a, b,

More information

Government Polytechnic Muzaffarpur.

Government Polytechnic Muzaffarpur. Government Polytechnic Muzaffarpur. Name of the Lab: COMPUTER PROGRAMMING LAB (MECH. ENGG. GROUP) Subject Code: 1625408 Experiment: 1 Aim: Programming exercise on executing a C program. If you are looking

More information

n Group of statements that are executed repeatedly while some condition remains true

n Group of statements that are executed repeatedly while some condition remains true Looping 1 Loops n Group of statements that are executed repeatedly while some condition remains true n Each execution of the group of statements is called an iteration of the loop 2 Example counter 1,

More information

C++ PROGRAMMING SKILLS Part 2 Programming Structures

C++ PROGRAMMING SKILLS Part 2 Programming Structures C++ PROGRAMMING SKILLS Part 2 Programming Structures If structure While structure Do While structure Comments, Increment & Decrement operators For statement Break & Continue statements Switch structure

More information

Loops (while and for)

Loops (while and for) Loops (while and for) CSE 1310 Introduction to Computers and Programming Alexandra Stefan 1 Motivation Was there any program we did (class or hw) where you wanted to repeat an action? 2 Motivation Name

More information

Problem Solving With Loops

Problem Solving With Loops To appreciate the value of loops, take a look at the following example. This program will calculate the average of 10 numbers input by the user. Without a loop, the three lines of code that prompt the

More information

Accelerating Information Technology Innovation

Accelerating Information Technology Innovation Accelerating Information Technology Innovation http://aiti.mit.edu Cali, Colombia Summer 2012 Lección 03 Control Structures Agenda 1. Block Statements 2. Decision Statements 3. Loops 2 What are Control

More information

Lecture 7: General Loops (Chapter 7)

Lecture 7: General Loops (Chapter 7) CS 101: Computer Programming and Utilization Jul-Nov 2017 Umesh Bellur (cs101@cse.iitb.ac.in) Lecture 7: General Loops (Chapter 7) The Need for a More General Loop Read marks of students from the keyboard

More information

PESIT Bangalore South Campus Hosur Road (1km before Electronic City), Bengaluru Department of Basic Science and Humanities

PESIT Bangalore South Campus Hosur Road (1km before Electronic City), Bengaluru Department of Basic Science and Humanities SOLUTION OF CONTINUOUS INTERNAL EVALUATION TEST -1 Date : 27-02 2018 Marks:60 Subject & Code : Programming in C and Data Structures- 17PCD23 Name of faculty : Dr. J Surya Prasad/Mr. Naushad Basha Saudagar

More information

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture 18 Switch Statement (Contd.) And Introduction to

More information

Chapter 4: Control structures

Chapter 4: Control structures Chapter 4: Control structures Repetition Loop Statements After reading and studying this Section, student should be able to Implement repetition control in a program using while statements. Implement repetition

More information

3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition)

3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition) Structures Programming in C++ Sequential Branching Repeating Loops (Repetition) 2 1 Loops Repetition is referred to the ability of repeating a statement or a set of statements as many times this is necessary.

More information

4.1. Structured program development Overview of C language

4.1. Structured program development Overview of C language 4.1. Structured program development 4.2. Data types 4.3. Operators 4.4. Expressions 4.5. Control flow 4.6. Arrays and Pointers 4.7. Functions 4.8. Input output statements 4.9. storage classes. UNIT IV

More information

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

Lecture 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 information

Lecture 10. Daily Puzzle

Lecture 10. Daily Puzzle Lecture 10 Daily Puzzle Imagine there is a ditch, 10 feet wide, which is far too wide to jump. Using only eight narrow planks, each no more than 9 feet long, construct a bridge across the ditch. Daily

More information

CHAPTER 5 FLOW OF CONTROL

CHAPTER 5 FLOW OF CONTROL CHAPTER 5 FLOW OF CONTROL PROGRAMMING CONSTRUCTS - In a program, statements may be executed sequentially, selectively or iteratively. - Every programming language provides constructs to support sequence,

More information

There are algorithms, however, that need to execute statements in some other kind of ordering depending on certain conditions.

There 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 information

Introduction to Programming

Introduction 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 information

C Program. Output. Hi everyone. #include <stdio.h> main () { printf ( Hi everyone\n ); }

C 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 information

Programming Basics and Practice GEDB029 Decision Making, Branching and Looping. Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029

Programming Basics and Practice GEDB029 Decision Making, Branching and Looping. Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029 Programming Basics and Practice GEDB029 Decision Making, Branching and Looping Prof. Dr. Mannan Saeed Muhammad bit.ly/gedb029 Decision Making and Branching C language possesses such decision-making capabilities

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.

& 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 information

Dept. of CSE, IIT KGP

Dept. of CSE, IIT KGP Control Flow: Looping CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Types of Repeated Execution Loop: Group of

More information

Programming for Electrical and Computer Engineers. Loops

Programming 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 information

Write a C program using arrays and structure

Write a C program using arrays and structure 03 Arrays and Structutes 3.1 Arrays Declaration and initialization of one dimensional, two dimensional and character arrays, accessing array elements. (10M) 3.2 Declaration and initialization of string

More information

Sudeshna Sarkar Dept. of Computer Science & Engineering. Indian Institute of Technology Kharagpur

Sudeshna Sarkar Dept. of Computer Science & Engineering. Indian Institute of Technology Kharagpur Programming and Data Structure Sudeshna Sarkar Dept. of Computer Science & Engineering. Indian Institute of Technology Kharagpur Shortcuts in Assignment Statements A+=C A=A+C A-=B A=A-B A*=D A=A*D A/=E

More information

Concept of algorithms Understand and use three tools to represent algorithms: Flowchart Pseudocode Programs

Concept 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 information

Q 1. Attempt any TEN of the following:

Q 1. Attempt any TEN of the following: Subject Code: 17212 Model Answer Page No: 1 / 26 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The

More information

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Lecture 10 For Loops and Arrays Outline Problem: How can I perform the same operations a fixed number of times? Considering for loops Performs same operations

More information

CSE 130 Introduction to Programming in C Control Flow Revisited

CSE 130 Introduction to Programming in C Control Flow Revisited CSE 130 Introduction to Programming in C Control Flow Revisited Spring 2018 Stony Brook University Instructor: Shebuti Rayana Control Flow Program Control Ø Program begins execution at the main() function.

More information

Chapter 5: Control Structures

Chapter 5: Control Structures Chapter 5: Control Structures In this chapter you will learn about: Sequential structure Selection structure if if else switch Repetition Structure while do while for Continue and break statements S1 2017/18

More information

Fundamentals of Computer Programming Using C

Fundamentals of Computer Programming Using C CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar Faculty Name: Ami D. Trivedi Class: FYBCA Subject: US01CBCA01 (Fundamentals of Computer Programming Using C) *UNIT 3 (Structured Programming, Library Functions

More information

STUDENT LESSON A12 Iterations

STUDENT LESSON A12 Iterations STUDENT LESSON A12 Iterations Java Curriculum for AP Computer Science, Student Lesson A12 1 STUDENT LESSON A12 Iterations INTRODUCTION: Solving problems on a computer very often requires a repetition of

More information

Example. CS 201 Selection Structures (2) and Repetition. Nested if Statements with More Than One Variable

Example. CS 201 Selection Structures (2) and Repetition. Nested if Statements with More Than One Variable CS 201 Selection Structures (2) and Repetition Debzani Deb Multiple-Alternative Decision Form of Nested if Nested if statements can become quite complex. If there are more than three alternatives and indentation

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) MODEL ANSWER

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) MODEL ANSWER Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate

More information

9/9/2017. If ( condition ) { statements ; ;

9/9/2017. If ( condition ) { statements ; ; C has three major decision making instruction, the if statement, the if- statement, & the switch statement. A fourth somewhat less important structure is the one which uses conditional operators In the

More information

Decision making with if Statement : - Control Statements. Introduction: -

Decision making with if Statement : - Control Statements. Introduction: - Control Statements Introduction: - Any C program if you consider, the set of statements are normally executed sequentially in the order in which they are written, and such programs have sequential structure

More information

Lecture 3. More About C

Lecture 3. More About C Copyright 1996 David R. Hanson Computer Science 126, Fall 1996 3-1 Lecture 3. More About C Programming languages have their lingo Programming language Types are categories of values int, float, char Constants

More information

Week 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018.

Week 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018. Week 2 Branching & Looping Gaddis: Chapters 4 & 5 CS 5301 Spring 2018 Jill Seaman 1 Relational Operators l relational operators (result is bool): == Equal to (do not use =)!= Not equal to > Greater than

More information

Unit 3. Operators. School of Science and Technology INTRODUCTION

Unit 3. Operators. School of Science and Technology INTRODUCTION INTRODUCTION Operators Unit 3 In the previous units (unit 1 and 2) you have learned about the basics of computer programming, different data types, constants, keywords and basic structure of a C program.

More information

Introduction. Pretest and Posttest Loops. Basic Loop Structures ว ทยาการคอมพ วเตอร เบ องต น Fundamentals of Computer Science

Introduction. Pretest and Posttest Loops. Basic Loop Structures ว ทยาการคอมพ วเตอร เบ องต น Fundamentals of Computer Science 204111 ว ทยาการคอมพ วเตอร เบ องต น Fundamentals of Computer Science ภาคการศ กษาท ภาคการศกษาท 1 ป ปการศกษา การศ กษา 2556 4. การเข ยนโปรแกรมพ นฐาน 4.5 โครงสร างควบค มแบบท าซ า รวบรวมโดย อ. ดร. อาร ร ตน ตรงร

More information

Midterm Exam. CSCI 2132: Software Development. March 4, Marks. Question 1 (10) Question 2 (10) Question 3 (10) Question 4 (10) Question 5 (5)

Midterm Exam. CSCI 2132: Software Development. March 4, Marks. Question 1 (10) Question 2 (10) Question 3 (10) Question 4 (10) Question 5 (5) Banner number: Name: Midterm Exam CSCI 2132: Software Development March 4, 2019 Marks Question 1 (10) Question 2 (10) Question 3 (10) Question 4 (10) Question 5 (5) Question 6 (5) Total (50) Instructions:

More information

Problem Solving and 'C' Programming

Problem Solving and 'C' Programming Problem Solving and 'C' Programming Targeted at: Entry Level Trainees Session 05: Selection and Control Structures 2007, Cognizant Technology Solutions. All Rights Reserved. The information contained herein

More information

C++ Programming: From Problem Analysis to Program Design, Third Edition

C++ Programming: From Problem Analysis to Program Design, Third Edition C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 5: Control Structures II (Repetition) Why Is Repetition Needed? Repetition allows you to efficiently use variables Can input,

More information

Conditionals. For exercises 1 to 27, indicate the output that will be produced. Assume the following declarations:

Conditionals. For exercises 1 to 27, indicate the output that will be produced. Assume the following declarations: Conditionals For exercises 1 to 27, indicate the output that will be produced. Assume the following declarations: final int MAX = 25, LIMIT = 100; int num1 = 12, num2 = 25, num3 = 87; 1. if (num1 < MAX)

More information

CS110D: PROGRAMMING LANGUAGE I

CS110D: PROGRAMMING LANGUAGE I CS110D: PROGRAMMING LANGUAGE I Computer Science department Lecture 5&6: Loops Lecture Contents Why loops?? While loops for loops do while loops Nested control structures Motivation Suppose that you need

More information

Basic Statements in C++ are constructed using tokens. The different statements are

Basic Statements in C++ are constructed using tokens. The different statements are CHAPTER 3 BASIC STATEMENTS Basic Statements in C++ are constructed using tokens. The different statements are Input/output Declaration Assignment Control structures Function call Object message Return

More information

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT OF MATHS, MJ COLLEGE T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,

More information

CHAPTER 9 FLOW OF CONTROL

CHAPTER 9 FLOW OF CONTROL CHAPTER 9 FLOW OF CONTROL FLOW CONTROL In a program statement may be executed sequentially, selectively or iteratively. Every program language provides constructs to support sequence, selection or iteration.

More information

V3 1/3/2015. Programming in C. Example 1. Example Ch 05 A 1. What if we want to process three different pairs of integers?

V3 1/3/2015. Programming in C. Example 1. Example Ch 05 A 1. What if we want to process three different pairs of integers? Programming in C 1 Example 1 What if we want to process three different pairs of integers? 2 Example 2 One solution is to copy and paste the necessary lines of code. Consider the following modification:

More information

Technical Questions. Q 1) What are the key features in C programming language?

Technical Questions. Q 1) What are the key features in C programming language? Technical Questions Q 1) What are the key features in C programming language? Portability Platform independent language. Modularity Possibility to break down large programs into small modules. Flexibility

More information

MA 511: Computer Programming Lecture 3: Partha Sarathi Mandal

MA 511: Computer Programming Lecture 3: Partha Sarathi Mandal MA 511: Computer Programming Lecture 3: 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 Last

More information

OVERVIEW OF C. Reads a string until enter key is pressed Outputs a string

OVERVIEW OF C. Reads a string until enter key is pressed Outputs a string 1 OVERVIEW OF C 1.1 Input and Output Statements Data input to the computer is processed in accordance with the instructions in a program and the resulting information is presented in the way that is acceptable

More information

C++ Programming Lecture 7 Control Structure I (Repetition) Part I

C++ Programming Lecture 7 Control Structure I (Repetition) Part I C++ Programming Lecture 7 Control Structure I (Repetition) Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department while Repetition Structure I Repetition structure Programmer

More information

Chapter 6. Section 6.4 Altering the Flow of Control. CS 50 Hathairat Rattanasook

Chapter 6. Section 6.4 Altering the Flow of Control. CS 50 Hathairat Rattanasook Chapter 6 Section 6.4 Altering the Flow of Control CS 50 Hathairat Rattanasook continue; The continue statement will skip the current iteration of a loop and jump to the next iteration. // continue in

More information

CMPT 102 Introduction to Scientific Computer Programming

CMPT 102 Introduction to Scientific Computer Programming CMP 102 Introduction to Scientific Computer Programming Control Structures while Loops continue; and break; statements Janice Regan, CMP 102, Sept. 2006 0 Control Structures hree methods of processing

More information