Welcome Guest | Sign in | Register

Home > C Programming > Loops > Questions and Answers

01. What will be the output of the following program?
main( )
{
int pskills[] = { 10, 20, 30, 40, 50 };
int i, *ptr ;
ptr = pskills;
for ( i = 0 ; i <4 ; i++ )
{
fun(ptr++);
printf ("\n%", *ptr ) ;
}
}
void fun(int *i)
{
*i = *i + 1;
}
A. 11 21 31 41 B. 20 30 40 50
C. 21 31 41 51 D. 10 20 30 40

Answer and Explanation

Answer: 20 30 40 50

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
02. What is the output of following program?
void main(){
int a=1;
while(a++<=1)
while(a++<=2);
printf("%d",a);
}
A. 1 B. 4
C. 5 D. 6

Answer and Explanation

Answer: 5

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
03. What is the output of following program?
void main(){
int a=1;
while(a++<=1)
while(a++<=2);
printf("%d",a);
}
A. 0 11 B. 0 12
C. 1 11 D. 1 12

Answer and Explanation

Answer: 1 12

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
04. What will be the output of the following program?
main( )
{
int gyan[] = { 10, 20, 30, 40, 50 };
int i, *ptr ;
ptr = gyan;
for ( i = 0 ; i <4 ; i++ )
{
fun(ptr++);
printf ( â??\n%dâ??, *ptr ) ;
}
}
void fun(int *i)
{
*i = *i + 1;
}
A. 11 21 31 41 B. 20 30 40 50
C. 21 31 41 51 D. 10 20 30 40

Answer and Explanation

Answer: 20 30 40 50

Explanation:
When we call the function fun() the current address contained by it will get passed and then it get incremented. For ex. If the base address is of the array is 100 then successive elements are stored at 102, 104, 106 and 108.
In the first call 100 get passed to fun() and ptr becomes 102. Now the called function fun() manipulates the value stored at 100 and in the main() function values at the address contained by ptr are getting printed.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
05. What is the output of following program?
void main(){
int a;
a=10;
do
while(a++<10);
while(a++<=11);
printf("%d",a);
}
A. 12 B. 13
C. 14 D. nothing display on screen.

Answer and Explanation

Answer: 14

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
06. What is the output of following program?
void main(){
int a,b;
for(a=b=10;a;printf("%d%d%d",a,b))
a=b++<=12;
printf("%d%d",a+10,b+10);
}
A. 1 12 1 12 1 13 0 14 10 24 B. 1 11 1 11 1 13 0 14 10 24
C. 1 11 1 12 1 13 0 14 10 24 D. 1 11 1 12 1 14 0 14 10 24

Answer and Explanation

Answer: 1 11 1 12 1 13 0 14 10 24

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
07. What is the output of following program?
void main(){
int i;
for(i=1;i++<=1;i++)
i++;
printf("%d",i);
}
A. 4 B. 5
C. 6 D. nothing display on screen

Answer and Explanation

Answer: 5

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
08. What is the output of following program?
void main(){
int i;
for(i=1;i++<=1;i++)
for(i++;i++<=6;i++)
i++;
printf("%d",i);
}
A. 11 B. 12
C. 13 D. none of these

Answer and Explanation

Answer: 12

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
09. What is the output of following program?
void main(){
int a;
a=1;
while(a<=10){
printf("%d",a);
if(a>3)
break;
a++;
}
printf("%d",a+10);
}
A. 1 2 3 4 13 B. 1 2 3 3 14
C. 1 2 3 3 13 D. 1 2 3 4 14

Answer and Explanation

Answer: 1 2 3 4 14

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
10. What is the output of following program?
void main(){
int a;
a=1;
while(a<=10){
printf("%d",a);
if(a>3 && a<8)
continue;
a++;
}
printf("%d",a+10);
}

A. 1 2 3 4 5 6 ...................infinite B. 1 2 3 4 5 5...................infinite
C. 1 2 3 4 4 4 ...................infinite D. 1 2 3 4 4 3 ...................infinite

Answer and Explanation

Answer: 1 2 3 4 4 4 ...................infinite

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum



Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.