LOOPING IN C. What would be the output of the following program main( ) { int j ; while ( j <= 10 ) { printf ( "\n%d", j ) ; j = j + 1 ; }

Slides:



Advertisements
Similar presentations
#include void main() { float x = 1.66, y = 1.75; printf(%f%f,ceil(x), floor(y)); }
Advertisements

Selection Feature of C: Decision making statements: It allow us to take decisions as to which code is to be executed next. Since these statements control.
Control Structures.
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Numerical Recipes The Art of Scientific Computing (with some applications in computational physics)
Introduction to C Systems Programming Concepts. Introduction to C A simple C Program A simple C Program –Variable Declarations –printf ( ) Compiling and.
For(int i = 1; i
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Lecture 9: Character and String
What is shape function ? shape function is a function that will give the displacements inside an element if its displacement at all the node locations.
Introduction to Assembly language
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
 2000 Prentice Hall, Inc. All rights reserved Fundamentals of Strings and Characters String declarations –Declare as a character array or a variable.
Array_strcpy void array_strcpy(char dest[], char src[]) { int i = 0; while (src[i] != '\0') { dest[i] = src[i]; i++; } dest[i] = '\0'; }
Sort the given string, without using string handling functions.
1 DATA ABSTRACTION: USER DEFINED TYPES AND THE CLASS.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Control Structures Nested ifs, switch statements.
A) 80 b) 53 c) 13 d) x 2 = : 10 = 3, x 3 = 309.
COMP1180 Review Date: 4 March, 2009 Time: 10:30am - 12:20pm Venue: –CS students -- FSC801C and FSC801D –IS and other students -- OEE1017 Remarks: – 1)
Character Input and Output C and Data Structures Baojian Hua
Display a 12-Month Calendar CS-2301 D-term Programming Assignment #2 12-Month Calendar CS-2301 System Programming C-term 2009 (Slides include materials.
More on Numerical Computation CS-2301 B-term More on Numerical Computation CS-2301, System Programming for Non-majors (Slides include materials from.
General Computer Science for Engineers CISC 106 Lecture 33 Dr. John Cavazos Computer and Information Sciences 05/11/2009.
If () else statement, switch statement, while () loop, do…while() loop and for( ; ; ) loop 1.
Craps!. Example: A Game of Chance Craps simulator Rules – Roll two dice 7 or 11 on first throw, player wins 2, 3, or 12 on first throw, player loses 4,
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
Introduction to Computing Lecture 07: Repetition and Loop Statements (Part II) Introduction to Computing Lecture 07: Repetition and Loop Statements (Part.
EC-111 Algorithms & Computing Lecture #4 Instructor: Jahan Zeb Department of Computer Engineering (DCE) College of E&ME NUST.
computer
/* C Programming for the Absolute Beginner */ // by Michael Vine #include main() { printf(“\nC you later\n”); system(“pause”); }
CECS 121 Test 1. Functions allow you to group program statements under one name C and C++ are case-sensitive so main(), MAIN(), and Main() are all different.
CS140: Intro to CS An Overview of Programming in C (part 3) by Erin Chambers.
1 ร. ศ. ดร. สุเทพ มาดารัศมี Understanding Pointers in C Chapter 10 of Programming with C Book.
C++ Programming Lecture 7 Control Structure I (Selection) – Part II The Hashemite University Computer Engineering Department.
1 Chapter 3: Loops and Logic. 2 Control Statements If statement Example NumberCheck.java Relational operators (, >=, ==, !=) Using code blocks with If.
Strings program. C Program to Check if a given String is Palindrome #include void main() { char string[25], reverse_string[25] = {'\0'}; int i, length.
Strings program. C Program to Check if a given String is Palindrome #include void main() { char string[25], reverse_string[25] = {'\0'}; int i, length.
int num = 22; if (num > 0) if (num % 5 == 0) System.out.println(num); else System.out.println(num + “ is negative”);
Char ch; ch ‘L’‘X’‘V’‘I’ As in Roman numerals Want to give each a value, n say switch (ch) { case ‘I’:n = 1; break; case ‘V’:n = 5; break; … default:cout.
CMSC 1041 More Loops ‘for’ loops and ‘do-while’ loops.
Review (before the 1 st test): while (conditions) { statements; } while loop: if/else if/else statements: if (conditions) { statements; } else if (different.
 2002 Prentice Hall. All rights reserved. 1 Chapter 4 – Control Structures Part 1 Outline Counter-Controlled Repetition: Example Sentinel-Controlled Repetition:
Engineering Computing I Chapter 3 Control Flow. Chapter 3 - Control Flow The control-flow of a language specify the order in which computations are performed.
1 CSC103: Introduction to Computer and Programming Lecture No 9.
Engr 0012 (04-1) LecNotes Engr 0012 (04-1) LecNotes Contrasting MATLAB with C MATLABC language Workspace - interactive computation No real.
C syntax (simplified) BNF. Program ::= [ ] Directives ::= [ ] ::= | |… ::=#include > ::=#define.
C language--Introduction. History 1970: B by Ken Thompson at AT&T Bell Lab 1972: C by Dennis Ritchie and Ken Tompson at At&T Bell Lab for UNIX 1978: “The.
Recursion what is it? how to build recursive algorithms
Decisions Chapter 4.
Arrays Declarations CSCI N305
معلم الصف الثالث الابتدائي
مبانی برنامه‌سازی با C++ جلسه دوم
Introduction to Programming
פרטים נוספים בסילבוס של הקורס
Variables, Loops, Decision Statements, etc
INC 161 , CPE 100 Computer Programming
CSC215 Homework Homework 02 Due date: Sep 30, 2016.
ФОНД “СОЦИАЛНО ПОДПОМАГАНЕ”
CSC215 Homework Homework 03 Due date: Oct 07, 2016.
Function Overloading.
Perfect squares class identifySquareButLessClever {
Fundamental Programming
Welcome back to Software Development!
Character Arrays char string1[] = “first”;
Strings #include <stdio.h>
Computer Security Password Policy.
Displaying Memory/Files
Characters and Strings Functions
Iteration Statement for
C++ Programming Lecture 7 Control Structure I (Selection) – Part II
Presentation transcript:

LOOPING IN C

What would be the output of the following program main( ) { int j ; while ( j <= 10 ) { printf ( "\n%d", j ) ; j = j + 1 ; }

What would be the output of the following program main( ) { int i = 1 ; while ( i <= 10 ) ; { printf ( "\n%d", i ) ; i++ ; }

What would be the output of the following program main( ) { int j ; while ( j <= 10 ) { printf ( "\n%d", j ) ; j = j + 1 ; }

What would be the output of the following program main( ) { int x = 1 ; while ( x == 1 ) { x = x - 1 ; printf ( "\n%d", x ) ; }

What would be the output of the following program main( ) { int x = 1 ; while ( x == 1 ) x = x - 1 ; printf ( "\n%d", x ) ; }

What would be the output of the following program main( ) { char x ; while ( x = 0 ; x <= 255 ; x++ ) printf ( "\nAscii value %d Character %c", x, x ) ; }

What would be the output of the following program main( ) { int x = 4, y, z ; y = --x ; z = x-- ; printf ( "\n%d %d %d", x, y, z ) ; }

What would be the output of the following program main( ) { int x = 4, y = 3, z ; z = x-- -y ; printf ( "\n%d %d %d", x, y, z ) ; }

What would be the output of the following program main( ) { while ( 'a' < 'b' ) printf ( "\nmalyalam is a palindrome" ) ; }

What would be the output of the following program main( ) { int i = 10 ; while ( i = 20 ) printf ( "\nA computer buff!" ) ; }

What would be the output of the following program main( ) { int i ; while ( i = 10 ) { printf ( "\n%d", i ) ; i = i + 1 ; }

What would be the output of the following program main( ) { float x = 1.1 ; while ( x == 1.1 ) { printf ( "\n%f", x ) ; x = x – 0.1 ; }

What would be the output of the following program main( ) { while ( '1' < '2' ) printf ( "\nIn while loop" ) ; }

What would be the output of the following program main( ) { char x ; for ( x = 0 ; x <= 255 ; x++ ) printf ( "\nAscii value %d Character %c", x, x ) ; }

What would be the output of the following program main( ) { int x = 4, y = 0, z ; while ( x >= 0 ) { x-- ; y++ ; if ( x == y ) continue ; else printf ( “\n%d %d”, x, y ) ; }

What would be the output of the following program main( ) { int x = 4, y = 0, z ; while ( x >= 0 ) { if ( x == y ) break ; else printf ( “\n%d %d”, x, y ) ; x-- ; y++ ; }

What would be the output of the following program main( ) { int i = 0 ; for ( ; i ; ) printf ( "\nHere is some mail for you" ) ; }

What would be the output of the following program main( ) { int i ; for ( i = 1 ; i <= 5 ; printf ( "\n%d", i ) ) ; i++ ; }

What would be the output of the following program main( ) { int i = 1, j = 1 ; for ( ; ; ) { if ( i > 5 ) break ; else j += i ; printf ( "\n%d", j ) ; i += j ; }

What would be the output of the following program main( ) { int i ; for ( i = 1 ; i <= 5 ; printf ( "\n%c", 65 ) ) ; i++ ; }