SlideShare a Scribd company logo
1 of 76
1
Jumping Statements in C
• break is a keyword of C language.
• It is used to transfer the control of program out of switch or looping
statement.
#include<stdio.h>
int main()
{
int i;
for(i=1;i<=5;i++)
{
if(i==3)
break;
printf(“n%d”,i);
}return(0);
}
2
continue
• continue is a keyword of C language.
• It is used with looping statements. It is reverse of break statement.
• The continue statement forces the loop to continue or execute the next
iteration.
• When the continue statement is executed in the loop, the code inside the
loop following the continue statement will be skipped and the next
iteration of the loop will begin.
• #include<stdio.h>
int main()
{
int i;
for(i=1;i<=5;i++)
{
if(i==3)
continue;
printf(“n%d”,i);
}return(0);
} 3
goto
• goto is a keyword of C language.
• It is used to transfer the control of program from one part of program
to another part of program.
• It can be used anywhere in a program.
• goto statement can be used in two ways:
• Forward goto
• In forward goto statement, the label exists after the goto statement
• Backward goto
• In backward goto statement, the label exists before the goto statement.
4
Forward goto Backward goto
#include<stdio.h>
int main()
{
printf(“nwelcome”);
goto end;
printf(“nHi”);
end:
printf(“nBie”);
return(0);
}
#include<stdio.h>
int main()
{
int a;
scanf("%d",&a);
k:printf("%dn",a);
a++;
if(a<3)
goto k;
return 0;
}
5
Revision Questions
Q1 What is the output of the following source code?
#include<stdio.h>
int main()
{
int n;
for (n = 9; n!=0; n--)
printf("n = %d", n--);
return 0;
}
6
Revision Questions
Q2 What is the output of the following source code?
#include <stdio.h>
int main()
{
int i = 0;
switch (i)
{
case '0': printf("CU");
break;
case '1': printf(“AU");
break;
default: printf("CU-AU");
}
return 0;
7
Revision Questions
Q3 What is the output of the following source code?
#include <stdio.h>
int main()
{
int i;
for (i = 1; i != 10; i += 2)
printf(“ MST 2 ");
return 0;
}
8
Revision Questions
Q5 find the output
#include<stdio.h>
int main()
{
int i = -5;
while (i <= 5)
{
if (i >= 0)
break;
else
{
i++;
}
printf(“ C PROGRAMMING");
}
return 0;
} 9
Revision Questions
Q4 Predict the output of the below program:#include <stdio.h>
int main()
{
int i = 3;
switch(i)
{
printf("Outside ");
case 1: printf(“Case 1");
break;
case 2: printf(“case 2");
break;
defau1t: printf(“default");
}
return 0;
}
10
Revision Questions
Q6 #include <stdio.h>
int main()
{
int i = 3;
while (i--)
{
int i = 100;
i--;
printf("%d ", i);
}
return 0;
}
11
Revision Questions
Q7 #include <stdio.h>
int main()
{
int x = 3;
if (x == 2);
x = 0;
if (x == 3)
x++;
else x += 2;
printf("x = %d", x);
return 0;
}
12
Revision Questions
Q 8 #include<stdio.h>
int main()
{
int a = 5;
switch(a)
{
default:
a = 4;
case 6:
a--;
case 5:
a = a+1;
case 1:
a = a-1;
}
printf("%d n", a);
return 0;
} 13
Revision Questions
Q9 What is the output of C Program.?
int main()
{
while(true)
{
printf("RABBIT");
break; }
return 0;
}
14
Revision Questions
Q10 What is the output of C Program.?
int main()
{ int a=5;
while(a==5)
{
printf("RABBIT");
break;
}
return 0;
}
15
Determine output:
main()
{
int i = abc(10);
printf("%d", --i);
}
int abc(int i)
{
return(i++);
}
16
What will be printed when this program is
executed?
int f(int x)
{
if(x <= 4)
return x;
return f(--x);
}
void main()
{
printf("%d ", f(7));
}
17
Revision Questions
Q11 What is the output of C Program.?
int main()
{ int a=5;
while(a=123)
{
printf("RABBITn");
break;
}
printf("GREEN");
return 0; }
18
Revision Questions
Q 12 What is the output of C Program.?
int main()
{
int a=5;
while(a >= 3);
{
printf(“TEDDYn");
break;
}
printf(“BEAR");
return 0;
}
19
Revision Questions
Q14 What is the output of C Program.?
int main() {
int k;
for(printf(“Hello "); printf(“CSE "); printf(“STUDENTS "))
{
break;
}
return 0;
}
20
Revision Questions
Q15 What will be the output of the following code?
#include <stdio.h>
int main()
{
int i = 0, j = 0;
while (i<5,j<10)
{
i++;
j++;
}
printf("%d %d", i, j);
}
21
Revision Questions
Q16 What will be the output of the following code?
int main()
{
int a = 0;
while(a++)
{
printf(“C programming");
}
return 0;
}
22
Revision Questions
Q17 What will be the output of the following code?
int main()
{
while(1);
{
printf("C Programming");
}
return 0;
}
23
Revision Questions
Q18 What will be the output of the following code?
int main()
{
int i,j,count;
count=0;
for(i=0; i<5; i++);
{
for(j=0;j<5;j++);
{
count++;
}
}
printf("%d",count);
return 0;
}
24
Revision Questions
Q19 What will be the output of the following code?
int main()
{
int i,j,k,count;
count=0;
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
count++;
}
}
printf("%d",count);
return 0;
}
25
Revision Questions
Q20 What will be the output of the following code?
int main()
{
int i,j;
for(i = 0,j=0;i<5;i++)
{
printf("%d%d--",i,j);
}
return 0;
}
26
Revision Questions
Q 21 What will be the output of following program ?
#include <stdio.h>
void main()
{
char cnt=0;
for(;cnt++;printf("%d",cnt)) ;
printf("%d",cnt);
}
27
Revision Questions
Q 24 What will be the output of following program ?
#include <stdio.h>
void main()
{
int tally;
for(tally=0;tally<10;++tally)
{
printf("#");
if(tally>6)
continue;
printf("%d",tally);
}
}
28
Revision Questions
Q 25 What will be the output of following program ?
#include <stdio.h>
void main()
{
int cnt=1;
do
{
printf("%d,",cnt);
cnt+=1;
}while(cnt>=10);
printf("nAfter loop cnt=%d",cnt);
printf("n");
}
29
Revision Questions
Q 27 What will be the output of following program ?
int main()
{
int a = 0;
while(a++);
{
printf("Cpp");
}
return 0;
}
30
Revision Questions
Q 28 What will be the output of following program
int main()
{
int i;
for(i = 0,i<5,i++)
{
printf("Hello");
}
return 0;
}
31
Revision Questions
Q 29 What will be the output of following program ?
#include <stdio.h>
void main()
{
int k = 0;
for (k)
printf("Hello");
}
32
Revision Questions
Q 30 What will be the output of following program ?
#include <stdio.h>
int main()
{
int i = 0;
for (; ; ;)
printf("In for loopn");
printf("After loopn");
}
33
Revision Questions
Q 31 What is output of below program?
int main()
{
for(; ;);
for(; ;);
printf("Hello");
return 0;
}
34
What is an Array in C language.?
A) A group of elements of the same data type.
B) An array contains more than one element
C) Array elements are stored in memory in continuous or contiguous
locations.
D) All the above.
35
An array index starts with value
A) 0
B) -1
C) 1
D) 2
36
int main()
{
int a[ ];
a[4] = {1,2,3,4};
printf("%d", a[0]);
}
a) 1
b) 2
c) 3
d) Compiler Error
37
If the two strings are identical, then strcmp() function returns
A. -1
B. 1
C. 0
D. None
38
Base address of an array represents the
a) Address of last element of an array
b) Address of second element of an array
c) Address of first element of an array
d) Number of elements
39
Array elements are always stored in ________ memory locations.?
a) Sequential
b) Random
c) Sequential and Random
d) None of the above
40
What is the output of this program?
void main()
{
int a[8] = {1,2,3,4,5};
printf("%d", a[5]);
}
A. 5
B. 6
C. 0
D. Garbage Value
41
#include <stdio.h>
int main()
{
char s1[] = "Hello";
char s2[] = "Hello";
if(s1 == s2)
printf("Same");
else
printf("Not Same");
return 0;
}
• A. Not Same
• B. Same
• C. Compilation Error
• D. None of the above
42
What is the output of this program?
#include<stdio.h>
int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}
43
What will be the output of the program ?
#include<stdio.h>
#include<string.h>
int main()
{
char str1[20] = "Hello", str2[20] = " World";
printf("%sn", strcpy(str2, strcat(str1, str2)));
return 0;
}
44
45
46
What will be the output of the following code?
void main()
{
int a[10];
printf("%d %d", a[-1], a[12]);
}
47
Which of the following correctly accesses the seventh element stored
in arr, an array with 100 elements?
A. arr[6]
B. arr[7]
C. arr{6}
D. arr{7}
E. None of these
48
• Which of the following function is more appropriate for reading in a
multi-word string?
A. scanf()
B. printf()
C. gets()
D. puts()
49
REVISION Questions
Predict output of following program
int main()
{
int i;
int arr[5] = {5};
for (i = 0; i < 5; i++)
printf("%d ", arr[i]);
return 0;
}
50
REVISION Questions
Q7 What is the output
int main()
{
int bus[3][] = {6,5,4,3,2,1};
printf("%d %d", bus[0][0], bus[2][1]);
return 0;
}
51
REVISION Questions
Q9 find the output
int main()
{
char str1[]=“CU";
char str2[20];
str2= str1;
printf("%s",str2);
return 0;
}
52
REVISION Questions
Q10 What is the output?
int main()
{
char str[25];
scanf("%s", str);
printf("%s",str);
return 0;
}
//input: New Delhi
53
#include<stdio.h>
int add(int a,int b=12)
{
return a+b;
}
int main()
{
int c ;
c=add(1,2);
printf("%d",c);
}
54
#include<stdio.h>
int add(int a,int b)
{
return a,return b;
}
int main()
{
int c ;
c=add(1,2);
printf("%d",c);
}
55
#include<stdio.h>
int add(int a,int b)
{
return a,b;
}
int main()
{
int c ;
c=add(1,2);
printf("%d",c);
return 0;
}
56
REVISION Questions
Find the output
void main()
{
int a;
printf("COUNT=");
a=show();
printf("%d", a);
}
int show()
{
return 15;
return 35;
}
57
Rohan writes the code for a function that computes the sum of n natural
numbers of the inputted number n.
int sum_n(int n)
{
if(n==1)
return 1;
else
missing statement
}
Fill in the missing statement.
58
• Sam is writing a code which has a function which calls itself. Which
programming concept is Sam using?
• The values passed to a function at the time of function calling are
knows as______________
• If we have to write a program to print first n natural ,which loop is
ideal?
59
Predict the Output of following C program ,if line 2 will be removed?
#include<stdio.h>
int add(int,int);//line 2
int add(int a,int b)
{
int sum=a+b;
return sum;
}
int main()
{
printf("%d",add(1,2));
return 0;
}
60
REVISION Questions
Q2 Find the output
int main()
{
int a[][] = {{1,2},{3,4}};
int i, j;
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
printf("%d ", a[i][j]);
return 0;
}
61
REVISION Questions
Q4 What is the output ?
int main()
{
char marks={'A','B','C'};
printf("%c", marks[0]);
}
62
REVISION Questions
Q16 What is the output?
63
21#include<stdio.h>
int main()
{
char str[7] = "IndiaRock";
printf("%sn", str);
return 0;
}
64
Revision Questions
Q 23 What will be the output of following program ?
#include < stdio.h >
int main()
{
int tally=0;
for(;;)
{
if(tally==10)
break;
printf("%d ",++tally);
}
return 0;
}
65
What is the output of C Program.?
int main()
{
int k, j;
for(k=1, j=10; k <= 5; k++)
{
printf("%d ", (k+j));
}
return 0;
}
66
find the output
#include<stdio.h>
int main()
{
int i = -5;
while (i <= 5)
{
if (i >= 0)
break;
else
{
i++;
continue;
}
printf(“ C PROGRAMMING");
} return 0; }
67
Revision Questions
Q 22 What will be the output of following program ?
#include <stdio.h>
void main()
{
int i=1;
while (i<=5)
{
printf("%d",i);
if (i==5)
goto print;
i++;
}
}
fun()
{
print:
printf("includehelp.com");
}
68
What is the output of C Program.?
int main()
{
int a=32;
do
{
printf("%d ", a);
a++;
if(a > 35)
break;
}while(1);
return 0;
}
69
void main()
{
printf(5+"Good Morningn");
}
A. Good Morning
B. M
C. Good
D. Morning
E. None of these
70
Let x be an array. Which of the following operations is/are illegal?
a) ++x
b) x+1
c) x++
d) x*2
71
What is the output of this program?
#include <stdio.h>
int main()
{
int arr[5] = {1,2,3,4,5};
int p, q, r;
p = ++arr[1];
q = arr[1]++;
r = arr[p++];
printf("%d, %d, %d", p, q, r);
return 0;
}
72
Guess the output.
#include<stdio.h>
int main()
{
int a[8] = {1,2,[4]=7,8,9};
for(int i=0;i<8;i++)
printf("%d ",a[i]);
}
73
# include <stdio.h>
int main()
{
char str1[] = “Chandigarh";
char str2[] = {‘c’,’h’,’a’,’n’,’d’,’I’,’g’,’a’,’r’,’h’};
int n1 = sizeof(str1)/sizeof(str1[0]);
int n2 = sizeof(str2)/sizeof(str2[0]);
printf("n1 = %d, n2 = %d", n1, n2);
return 0;
}
74
• Which loop is faster in C Language, for, while or Do While.?
• a) for
• b) while
• c) do while
• d) All work at same speed
75
Revision Questions
Q 26 What will be the output in given input?
• When, input: 'a' and 1
int main()
{
int n,i=0;
while(scanf("%d",&n)==1)
{
printf("ENDn");
}
return 0;
}
76

More Related Content

Similar to UNIT 2 LOOP CONTROL.pptx

important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomeshpraveensomesh
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solutionAzhar Javed
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbTUSHARGAURAV11
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbTUSHARGAURAV11
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...MaruMengesha
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILEDipta Saha
 
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdfchoconyeuquy
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfYashwanthCse
 
sodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfsodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfMuhammadMaazShaik
 
Some stuff about C++ and development
Some stuff about C++ and developmentSome stuff about C++ and development
Some stuff about C++ and developmentJon Jagger
 

Similar to UNIT 2 LOOP CONTROL.pptx (20)

C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
 
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjbpointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
pointer.ppt hfkogfhkigfvjjgdsyhhgfdfghjb
 
FSOFT - Test Java Exam
FSOFT - Test Java ExamFSOFT - Test Java Exam
FSOFT - Test Java Exam
 
C questions
C questionsC questions
C questions
 
Ansi c
Ansi cAnsi c
Ansi c
 
operators.ppt
operators.pptoperators.ppt
operators.ppt
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
175035 cse lab-05
175035 cse lab-05 175035 cse lab-05
175035 cse lab-05
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdf
 
Hargun
HargunHargun
Hargun
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
 
Vcs16
Vcs16Vcs16
Vcs16
 
sodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdfsodapdf-converted into ppt presentation(1).pdf
sodapdf-converted into ppt presentation(1).pdf
 
Some stuff about C++ and development
Some stuff about C++ and developmentSome stuff about C++ and development
Some stuff about C++ and development
 

More from Abhishekkumarsingh630054

More from Abhishekkumarsingh630054 (7)

lecture 10 Recursive Function and Macros.ppt
lecture 10 Recursive Function and Macros.pptlecture 10 Recursive Function and Macros.ppt
lecture 10 Recursive Function and Macros.ppt
 
NIFT-Sample-Paper-2020-btech-Programme-GAT.pdf
NIFT-Sample-Paper-2020-btech-Programme-GAT.pdfNIFT-Sample-Paper-2020-btech-Programme-GAT.pdf
NIFT-Sample-Paper-2020-btech-Programme-GAT.pdf
 
PPT DMA.pptx
PPT  DMA.pptxPPT  DMA.pptx
PPT DMA.pptx
 
7. Pointers and Virtual functions final -3.pptx
7. Pointers and Virtual functions final -3.pptx7. Pointers and Virtual functions final -3.pptx
7. Pointers and Virtual functions final -3.pptx
 
Chapter 8 Structure Part 2 (1).pptx
Chapter 8 Structure Part 2 (1).pptxChapter 8 Structure Part 2 (1).pptx
Chapter 8 Structure Part 2 (1).pptx
 
DT-2 Exp 2.3_2.pdf
DT-2 Exp 2.3_2.pdfDT-2 Exp 2.3_2.pdf
DT-2 Exp 2.3_2.pdf
 
ar vr mr certificate.pdf
ar vr mr certificate.pdfar vr mr certificate.pdf
ar vr mr certificate.pdf
 

Recently uploaded

UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 

UNIT 2 LOOP CONTROL.pptx

  • 1. 1
  • 2. Jumping Statements in C • break is a keyword of C language. • It is used to transfer the control of program out of switch or looping statement. #include<stdio.h> int main() { int i; for(i=1;i<=5;i++) { if(i==3) break; printf(“n%d”,i); }return(0); } 2
  • 3. continue • continue is a keyword of C language. • It is used with looping statements. It is reverse of break statement. • The continue statement forces the loop to continue or execute the next iteration. • When the continue statement is executed in the loop, the code inside the loop following the continue statement will be skipped and the next iteration of the loop will begin. • #include<stdio.h> int main() { int i; for(i=1;i<=5;i++) { if(i==3) continue; printf(“n%d”,i); }return(0); } 3
  • 4. goto • goto is a keyword of C language. • It is used to transfer the control of program from one part of program to another part of program. • It can be used anywhere in a program. • goto statement can be used in two ways: • Forward goto • In forward goto statement, the label exists after the goto statement • Backward goto • In backward goto statement, the label exists before the goto statement. 4
  • 5. Forward goto Backward goto #include<stdio.h> int main() { printf(“nwelcome”); goto end; printf(“nHi”); end: printf(“nBie”); return(0); } #include<stdio.h> int main() { int a; scanf("%d",&a); k:printf("%dn",a); a++; if(a<3) goto k; return 0; } 5
  • 6. Revision Questions Q1 What is the output of the following source code? #include<stdio.h> int main() { int n; for (n = 9; n!=0; n--) printf("n = %d", n--); return 0; } 6
  • 7. Revision Questions Q2 What is the output of the following source code? #include <stdio.h> int main() { int i = 0; switch (i) { case '0': printf("CU"); break; case '1': printf(“AU"); break; default: printf("CU-AU"); } return 0; 7
  • 8. Revision Questions Q3 What is the output of the following source code? #include <stdio.h> int main() { int i; for (i = 1; i != 10; i += 2) printf(“ MST 2 "); return 0; } 8
  • 9. Revision Questions Q5 find the output #include<stdio.h> int main() { int i = -5; while (i <= 5) { if (i >= 0) break; else { i++; } printf(“ C PROGRAMMING"); } return 0; } 9
  • 10. Revision Questions Q4 Predict the output of the below program:#include <stdio.h> int main() { int i = 3; switch(i) { printf("Outside "); case 1: printf(“Case 1"); break; case 2: printf(“case 2"); break; defau1t: printf(“default"); } return 0; } 10
  • 11. Revision Questions Q6 #include <stdio.h> int main() { int i = 3; while (i--) { int i = 100; i--; printf("%d ", i); } return 0; } 11
  • 12. Revision Questions Q7 #include <stdio.h> int main() { int x = 3; if (x == 2); x = 0; if (x == 3) x++; else x += 2; printf("x = %d", x); return 0; } 12
  • 13. Revision Questions Q 8 #include<stdio.h> int main() { int a = 5; switch(a) { default: a = 4; case 6: a--; case 5: a = a+1; case 1: a = a-1; } printf("%d n", a); return 0; } 13
  • 14. Revision Questions Q9 What is the output of C Program.? int main() { while(true) { printf("RABBIT"); break; } return 0; } 14
  • 15. Revision Questions Q10 What is the output of C Program.? int main() { int a=5; while(a==5) { printf("RABBIT"); break; } return 0; } 15
  • 16. Determine output: main() { int i = abc(10); printf("%d", --i); } int abc(int i) { return(i++); } 16
  • 17. What will be printed when this program is executed? int f(int x) { if(x <= 4) return x; return f(--x); } void main() { printf("%d ", f(7)); } 17
  • 18. Revision Questions Q11 What is the output of C Program.? int main() { int a=5; while(a=123) { printf("RABBITn"); break; } printf("GREEN"); return 0; } 18
  • 19. Revision Questions Q 12 What is the output of C Program.? int main() { int a=5; while(a >= 3); { printf(“TEDDYn"); break; } printf(“BEAR"); return 0; } 19
  • 20. Revision Questions Q14 What is the output of C Program.? int main() { int k; for(printf(“Hello "); printf(“CSE "); printf(“STUDENTS ")) { break; } return 0; } 20
  • 21. Revision Questions Q15 What will be the output of the following code? #include <stdio.h> int main() { int i = 0, j = 0; while (i<5,j<10) { i++; j++; } printf("%d %d", i, j); } 21
  • 22. Revision Questions Q16 What will be the output of the following code? int main() { int a = 0; while(a++) { printf(“C programming"); } return 0; } 22
  • 23. Revision Questions Q17 What will be the output of the following code? int main() { while(1); { printf("C Programming"); } return 0; } 23
  • 24. Revision Questions Q18 What will be the output of the following code? int main() { int i,j,count; count=0; for(i=0; i<5; i++); { for(j=0;j<5;j++); { count++; } } printf("%d",count); return 0; } 24
  • 25. Revision Questions Q19 What will be the output of the following code? int main() { int i,j,k,count; count=0; for(i=0;i<5;i++) { for(j=0;j<5;j++) { count++; } } printf("%d",count); return 0; } 25
  • 26. Revision Questions Q20 What will be the output of the following code? int main() { int i,j; for(i = 0,j=0;i<5;i++) { printf("%d%d--",i,j); } return 0; } 26
  • 27. Revision Questions Q 21 What will be the output of following program ? #include <stdio.h> void main() { char cnt=0; for(;cnt++;printf("%d",cnt)) ; printf("%d",cnt); } 27
  • 28. Revision Questions Q 24 What will be the output of following program ? #include <stdio.h> void main() { int tally; for(tally=0;tally<10;++tally) { printf("#"); if(tally>6) continue; printf("%d",tally); } } 28
  • 29. Revision Questions Q 25 What will be the output of following program ? #include <stdio.h> void main() { int cnt=1; do { printf("%d,",cnt); cnt+=1; }while(cnt>=10); printf("nAfter loop cnt=%d",cnt); printf("n"); } 29
  • 30. Revision Questions Q 27 What will be the output of following program ? int main() { int a = 0; while(a++); { printf("Cpp"); } return 0; } 30
  • 31. Revision Questions Q 28 What will be the output of following program int main() { int i; for(i = 0,i<5,i++) { printf("Hello"); } return 0; } 31
  • 32. Revision Questions Q 29 What will be the output of following program ? #include <stdio.h> void main() { int k = 0; for (k) printf("Hello"); } 32
  • 33. Revision Questions Q 30 What will be the output of following program ? #include <stdio.h> int main() { int i = 0; for (; ; ;) printf("In for loopn"); printf("After loopn"); } 33
  • 34. Revision Questions Q 31 What is output of below program? int main() { for(; ;); for(; ;); printf("Hello"); return 0; } 34
  • 35. What is an Array in C language.? A) A group of elements of the same data type. B) An array contains more than one element C) Array elements are stored in memory in continuous or contiguous locations. D) All the above. 35
  • 36. An array index starts with value A) 0 B) -1 C) 1 D) 2 36
  • 37. int main() { int a[ ]; a[4] = {1,2,3,4}; printf("%d", a[0]); } a) 1 b) 2 c) 3 d) Compiler Error 37
  • 38. If the two strings are identical, then strcmp() function returns A. -1 B. 1 C. 0 D. None 38
  • 39. Base address of an array represents the a) Address of last element of an array b) Address of second element of an array c) Address of first element of an array d) Number of elements 39
  • 40. Array elements are always stored in ________ memory locations.? a) Sequential b) Random c) Sequential and Random d) None of the above 40
  • 41. What is the output of this program? void main() { int a[8] = {1,2,3,4,5}; printf("%d", a[5]); } A. 5 B. 6 C. 0 D. Garbage Value 41
  • 42. #include <stdio.h> int main() { char s1[] = "Hello"; char s2[] = "Hello"; if(s1 == s2) printf("Same"); else printf("Not Same"); return 0; } • A. Not Same • B. Same • C. Compilation Error • D. None of the above 42
  • 43. What is the output of this program? #include<stdio.h> int main() { int a[5] = {5, 1, 15, 20, 25}; int i, j, m; i = ++a[1]; j = a[1]++; m = a[i++]; printf("%d, %d, %d", i, j, m); return 0; } 43
  • 44. What will be the output of the program ? #include<stdio.h> #include<string.h> int main() { char str1[20] = "Hello", str2[20] = " World"; printf("%sn", strcpy(str2, strcat(str1, str2))); return 0; } 44
  • 45. 45
  • 46. 46
  • 47. What will be the output of the following code? void main() { int a[10]; printf("%d %d", a[-1], a[12]); } 47
  • 48. Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements? A. arr[6] B. arr[7] C. arr{6} D. arr{7} E. None of these 48
  • 49. • Which of the following function is more appropriate for reading in a multi-word string? A. scanf() B. printf() C. gets() D. puts() 49
  • 50. REVISION Questions Predict output of following program int main() { int i; int arr[5] = {5}; for (i = 0; i < 5; i++) printf("%d ", arr[i]); return 0; } 50
  • 51. REVISION Questions Q7 What is the output int main() { int bus[3][] = {6,5,4,3,2,1}; printf("%d %d", bus[0][0], bus[2][1]); return 0; } 51
  • 52. REVISION Questions Q9 find the output int main() { char str1[]=“CU"; char str2[20]; str2= str1; printf("%s",str2); return 0; } 52
  • 53. REVISION Questions Q10 What is the output? int main() { char str[25]; scanf("%s", str); printf("%s",str); return 0; } //input: New Delhi 53
  • 54. #include<stdio.h> int add(int a,int b=12) { return a+b; } int main() { int c ; c=add(1,2); printf("%d",c); } 54
  • 55. #include<stdio.h> int add(int a,int b) { return a,return b; } int main() { int c ; c=add(1,2); printf("%d",c); } 55
  • 56. #include<stdio.h> int add(int a,int b) { return a,b; } int main() { int c ; c=add(1,2); printf("%d",c); return 0; } 56
  • 57. REVISION Questions Find the output void main() { int a; printf("COUNT="); a=show(); printf("%d", a); } int show() { return 15; return 35; } 57
  • 58. Rohan writes the code for a function that computes the sum of n natural numbers of the inputted number n. int sum_n(int n) { if(n==1) return 1; else missing statement } Fill in the missing statement. 58
  • 59. • Sam is writing a code which has a function which calls itself. Which programming concept is Sam using? • The values passed to a function at the time of function calling are knows as______________ • If we have to write a program to print first n natural ,which loop is ideal? 59
  • 60. Predict the Output of following C program ,if line 2 will be removed? #include<stdio.h> int add(int,int);//line 2 int add(int a,int b) { int sum=a+b; return sum; } int main() { printf("%d",add(1,2)); return 0; } 60
  • 61. REVISION Questions Q2 Find the output int main() { int a[][] = {{1,2},{3,4}}; int i, j; for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) printf("%d ", a[i][j]); return 0; } 61
  • 62. REVISION Questions Q4 What is the output ? int main() { char marks={'A','B','C'}; printf("%c", marks[0]); } 62
  • 63. REVISION Questions Q16 What is the output? 63
  • 64. 21#include<stdio.h> int main() { char str[7] = "IndiaRock"; printf("%sn", str); return 0; } 64
  • 65. Revision Questions Q 23 What will be the output of following program ? #include < stdio.h > int main() { int tally=0; for(;;) { if(tally==10) break; printf("%d ",++tally); } return 0; } 65
  • 66. What is the output of C Program.? int main() { int k, j; for(k=1, j=10; k <= 5; k++) { printf("%d ", (k+j)); } return 0; } 66
  • 67. find the output #include<stdio.h> int main() { int i = -5; while (i <= 5) { if (i >= 0) break; else { i++; continue; } printf(“ C PROGRAMMING"); } return 0; } 67
  • 68. Revision Questions Q 22 What will be the output of following program ? #include <stdio.h> void main() { int i=1; while (i<=5) { printf("%d",i); if (i==5) goto print; i++; } } fun() { print: printf("includehelp.com"); } 68
  • 69. What is the output of C Program.? int main() { int a=32; do { printf("%d ", a); a++; if(a > 35) break; }while(1); return 0; } 69
  • 70. void main() { printf(5+"Good Morningn"); } A. Good Morning B. M C. Good D. Morning E. None of these 70
  • 71. Let x be an array. Which of the following operations is/are illegal? a) ++x b) x+1 c) x++ d) x*2 71
  • 72. What is the output of this program? #include <stdio.h> int main() { int arr[5] = {1,2,3,4,5}; int p, q, r; p = ++arr[1]; q = arr[1]++; r = arr[p++]; printf("%d, %d, %d", p, q, r); return 0; } 72
  • 73. Guess the output. #include<stdio.h> int main() { int a[8] = {1,2,[4]=7,8,9}; for(int i=0;i<8;i++) printf("%d ",a[i]); } 73
  • 74. # include <stdio.h> int main() { char str1[] = “Chandigarh"; char str2[] = {‘c’,’h’,’a’,’n’,’d’,’I’,’g’,’a’,’r’,’h’}; int n1 = sizeof(str1)/sizeof(str1[0]); int n2 = sizeof(str2)/sizeof(str2[0]); printf("n1 = %d, n2 = %d", n1, n2); return 0; } 74
  • 75. • Which loop is faster in C Language, for, while or Do While.? • a) for • b) while • c) do while • d) All work at same speed 75
  • 76. Revision Questions Q 26 What will be the output in given input? • When, input: 'a' and 1 int main() { int n,i=0; while(scanf("%d",&n)==1) { printf("ENDn"); } return 0; } 76

Editor's Notes

  1. Infinite loop
  2. Cu AU
  3. INFINITE LOOP
  4. C PROGRAMMING 5 times
  5. Nothing gets printed
  6. 99 99 99
  7. X=2
  8. 5
  9. COMPILE TIME ERROR
  10. RABBIT
  11. RABBIT GREEN
  12. INFINITE LOOP WITH NO ANSWER
  13. HELLO CSE
  14. 10 10
  15. Nothing will be printed
  16. Infinite loop
  17. 1
  18. 25
  19. 00—10—20—30—40--
  20. 1 Before entering into the for loop the CHECK CONDITION is "evaluated". Here it evaluates to 0 (false) and comes out of the loop, and i is incremented (note the semicolon after the for loop).
  21. #0#1#2#3#4#5#6###
  22. 1, After loop cnt=2 do while is an exit controlled loop, here loop body executed first, then condition will be checked.
  23. Cpp
  24. for loop should have semicolumn ; not comma , in its syntax. Using , instead of ; produces compilation error.
  25. error
  26. Hint: blank for loop with ; ; is always infinite loop. printf() will never executed in this program.
  27. Explanation: The base address of s1 and s2 are checked which are not equal and hence the else part will execute.
  28. A. 3, 2, 15 Explanation:- >> int a[5] = {5, 1, 15, 20, 25}; The variable arr is declared as an integer array with a size of 5 and it is initialized to a[0] = 5, a[1] = 1, a[2] = 15, a[3] = 20, a[4] = 25. >> int i, j, m; The variable i, j, m are declared as an integer type. >> i = ++a[1]; becomes i = ++1; Hence i = 2 and a[1] = 2 >> j = a[1]++; becomes j = 2++; Hence j = 2 and a[1] = 3. >> m = a[i++]; becomes m = a[2]; Hence m = 15 and i is incremented by 1(i++ means 2++ so i=3) >> printf(“%d, %d, %d”, i, j, m); It prints the value of the variables i, j, m Hence the output of the program is 3, 2, 15.
  29. Hello World
  30. 5 0 0 0 0
  31. ary[3][] has missing column count. Column count is a must for any multidimensional array.
  32. Direct assignment not possible error
  33. New
  34. error
  35. 2
  36. 15
  37. error
  38. Compile time error
  39. 10
  40. Here str[] has declared as 7 character array and into a 8 character is stored. This will result in overwriting of the byte beyond 7 byte reserved for '\0'.
  41. 1 2 3 4 5 6 7 8 9 10 for(; ;) it is possible in c, there is no need to place condition with in the for(), you can place condition with in the body of the loop.
  42. 11 12 13 14 15
  43. compiler error: Undefined label ‘print’ in function main. Labels have functions scope, in other words the scope of the labels is limited to functions. The label ‘print’ is available in function fun() Hence it is not visible in function main.
  44. 32 33 34 35
  45. C. 4 3 4
  46. 1 2 0 0 7 8 9 0
  47. No output and END scanf function return integer value i.e. 1 if successful read data otherwise 0 in unsuccessfully read data. 1_ For, input ‘a’, scanf return 0 and while will not execute. 2_ For, input 1, scanf return 1 and while will be execute.