JUMP STATEMENT C++ has the four statements that perform an unconditional branch. They are, 1. return 2. goto 3. break 4. continue In addition to four statements.

Slides:



Advertisements
Similar presentations
Sort the given string, without using string handling functions.
Advertisements

1 Conditional Statement. 2 Conditional Statements Allow different sets of instructions to be executed depending on truth or falsity of a logical condition.
CSCI 130 Advanced Program Control Chapter 8. Program Controls so far for loop while loop do…while loop.
Homework Any Questions?. Statements / Blocks, Section 3.1 An expression becomes a statement when it is followed by a semicolon x = 0; Braces are used.
1 MATERI PENDUKUNG JUMP Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
1 CS 192 Lecture 9 Winter 2003 December 19, 2003 Dr. Shafay Shamail.
Advanced Programming in the UNIX Environment Hop Lee.
CLASS XI By Sumita Arora
JAVA Control Statement.
Chapter 4 Program Control Statements
Programming Fundamentals Lecture 4. In the Previous Lecture Basic structure of C program Variables and Data types Operators ‘cout’ and ‘cin’ for output.
Control Statements (Decision Making)
OBJECTIVES  Illustration of the Concept of Control Flow  Types of Control Flow  Knowledge about conditional and repetitive statements.  Make more.
Controlling Execution Dong Shao, Nanjing Unviersity.
Chapter 3. Outline Relational Operators Loops Decisions Logical Operators Precedence Summary.
Decision making statements. Decision making statements are used to skip or to execute a group of statements based on the result of some condition. The.
Looping Construct or Statements. Introduction of looping constructs In looping,a sequence of statements are executed until some condition for termination.
CSC1201: Programming Language 2 Lecture 1 Level 2 Course Nouf Aljaffan (C) CSC 1201 Course at KSU1.
Decision Making It is used to change the order of the program based on condition. Categories: – Sequential structure – Selection structure – Iteration.
Loops cause a section of a program to be repeated a certain number of times. The repetition continues while a condition remains true. When a condition.
Repetition Statements (Loops) The do while Loop The last iteration structure in C++ is the do while loop. A do while loop repeats a statement or.
CS 161 Introduction to Programming and Problem Solving Chapter 18 Control Flow Through C++ Program Herbert G. Mayer, PSU Status 10/8/2014 Initial content.
Chapter : 9 Control Statements Control Flow: A control flow Statement regulates the order in which statements get executed. F Flow-order in which the computer.
Statements
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
For Loop Lecture No 8. Definition In computer science a for loop is a programming language statement which allows code to be repeatedly executed. A for.
We have to discuss following:-  Statements  Statement flow control  Selection statement  Iteration statement.
Asstt. Prof Mandeep Kaur Computer Dept. TOPIC: Control Statements in C language.
Control Flow Statements
Course Title Object Oriented Programming with C++ Course instructor ADEEL ANJUM Chapter No: 04 loops 1 BY ADEEL ANJUM ( MSc - cs, CCNA, WEB DEVELOPER )
Loops and Logic. Making Decisions Conditional operator Switch Statement Variable scope Loops Assertions.
CONTENTS Loop Statements Parts of a loop Types of Loops Nested Loops
BY ILTAF MEHDI(MCS,MCSE, CCNA) 1. INSTRUCTOR: ILTAF MEHDI (MCS, MCSE, CCNA, Web Developer) BY ILTAF MEHDI(MCS,MCSE, CCNA) 2 Programming Fundamentals Chapter.
Control Structures (Repetition structure) Jump Statements
Control Structures Introduction
WHILE, DO-WHILE AND FOR LOOPS
Chapter 6: Loops.
The setw Manipulator The setw manipulator causes the number (or string) that follows it in the stream to be printed within a field n characters wide, where.
C Program Controls + Flow Structure
MULTI-DIMENSIONAL ARRAY
Control Flow based Testing
Programmazione I a.a. 2017/2018.
Intro to Programming Week # 5 Repetition Structure Lecture # 9
Flow of Control.
11/10/2018.
Flow of Control.
IF if (condition) { Process… }
COPY ENGR.SABA MUGHAL FROM COMPUTER SYSTEMS DEPARTMENT
Example Problems for Exam#2 (covers chapters 5, 6, 7, 8, 9)
Loops in C.
Operators.
Control Structures Repetition
Flow of Control.
CSC215 Lecture Flow Control.
CSC215 Lecture Control Flow.
Flow of Control.
Homework Any Questions?.
Abstract Data Type Abstract Data Type as a design tool
ECE 103 Engineering Programming Chapter 20 Change in Flow of Control
ECE 103 Engineering Programming Chapter 18 Iteration
Decision making and control functions
ENGR.SABA MUGHAL FROM COMPUTER SYSTEM DEPARTMENT
Department of Computer Science
CSC215 Lecture Control Flow.
Programming Fundamental
Programming Fundamental
Storage Classes.
The return Statement © 2018 Kris Jordan.
break & continue Statements
Programming Fundamental-1
Presentation transcript:

JUMP STATEMENT C++ has the four statements that perform an unconditional branch. They are, 1. return 2. goto 3. break 4. continue In addition to four statements C++ library function provides exit() that helps you break out of the program.

JUMP STATEMENT – goto Example start : cout<<“\n”<<++a; if(a<50) goto start; NOTE: Label may not immediately precede the closing right brace. If so then a null statement may be used. For example ……. { goto last; ….. last: // wrong! }

break STATEMENT -EXAMPLE for( int;test expression;update expression) { statement if(val>2000) break; ….. statement; } statement 3;

break STATEMENT -EXAMPLE do { statement if(val>2000) break; ….. statement; } while (test expression); statement 3;

THE continue STATEMENT while (test expression) { statement if(condition) continue; ….. statement; } statement 3;

THE continue STATEMENT EXAMPLE for (int; test expression; updateexpression ) { statement if(condition) continue; ….. statement; } statement 3;

THE continue STATEMENT EXAMPLE do { statement if(condition) continue; ….. statement; } while (test expression); statement 3;

THE exit() FUNTION The exit() function causes the program to terminate as soon as it is encountered. The exit() function is a C++ standard library function defined in process.h file. which must be included in the program that uses exit() function

EXAMPLE-exit() FUNCTION // Program to check entered number is prime number or not #include<iostream.h> #include<conio.h> #include<process.h> void main() { int num,i; clrscr(); cout<<"Enter the Number: "; cin>>num; for(i=2; i<=num/2;++i) { cout<<"\n Not a Prime Number"; exit(0); } cout<<"\n It is Prime Number"; getch(); Enter the Number: 4 Not a Prime Number

THANK YOU