Note 1

Take Note:

Take a note while surfing.





Note With Ink

Give your Note a Colorful Tag.




Easy to Access

Stay on same information and in Sync wherever you are.

Note 2

Take Note:

Organize your information,It may take Shape.





Think With Ink

Differ your Content by Color.




Easy to Access

Easy to pull up your content from anywhere anytime.

Note 3

Take Note:

Don't Let information to miss,Because it take shape





Note With Ink

Simple an Easy Way to take a note.




Easy to Access

Get the same in next visit.

C Programming :: Loop Control

Home > C Programming > Loop Control > General Questions

1. What is the final value of i and final value of LOOPS ?

#include
int main()
{
int i,j,k,l,lc=0;

printf("Enter the number string:<1234 567>\n");
scanf("%2d%d%1d",&i,&j,&k);
for(;k;k--,i++)
for(l=0;printf("%d %d\n",i,l);)
printf("LOOPS= %d\n", lc-1);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

2. What is the output of the following problem ?

#include
int main()
{
int i;
for (i=9;i<13; i++)
printf("%d %0x ",i,i);
return 0;
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option E

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

3. #include
int main(){
for(printf("1");!printf("0");printf("2"))
printf("Aditya");
return 0;
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

4. void main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q;
}
for(j=0;j<5;j++){
printf(" %d ",*p);
++p;
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

Here pointer c is assigned to both p and q.
In first loop, only q is incremented and not c , the value 2 will be printed 5 times.
In second loop p itself is incremented. So the values 2 3 4 6 5 will be printed

Workspace

Tags:

No Tags on this question yet!

5. What is the output of the following C Program?

#include
int main()
{
int i=0;
for(;i++;printf("%d",i)) ;
printf("%d",i);
return 0;
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

before entering into the for loop the checking 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).

Workspace

Tags:

No Tags on this question yet!

6. What is the output of the following C Program?

#include
int main()
{
unsigned int i;
for(i=1;i>-2;i--)
printf("c aptitude");
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option C

Explanation:

Here "I" is an unsigned integer. It is compared with a signed value. Since the both types doesn't match, signed is promoted to unsigned value.
The unsigned equivalent of -2 is a huge value so condition becomes false and control comes out of the loop.

Workspace

Tags:

No Tags on this question yet!

7. What is the output of the following C Program?

#include
void main()
{
while(1){
if(printf("%d",printf("%d")))
break;
else
continue;
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

The inner printf executes first to print some garbage value. The printf returns no of characters printed and this value also cannot be predicted. Still the outer printf prints something and so returns a non-zero value. So it encounters the break statement and comes out of the while statement.

Workspace

Tags:

No Tags on this question yet!

8. What is the output of the following C Program?

#include
void main()
{
signed char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option D

Explanation:

Notice the semicolon at the end of the for loop. Tee initial value of the i is set to 0.
The inner loop executes to increment the value from
0 to 127 and then it rotates to the negative value of -128.
The condition in the for loop fails and so comes out of the for loop. It prints the current value of i that is -128.

Workspace

Tags:

No Tags on this question yet!

9. What will be output of the following "c" code?

#include
int main() {
int i;
for(i=0;i<5;i++){
int i=10;
printf(" %d",i);
i++;
}
return 0;
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!

10. Find out the error in the 'while' loop, if any ?

void main()
{
int i= 1;
while ()
{
printf("%d", i++);
if (i > 10)
break;
}
}

View Answer | Discuss in Forum | Workspace | Asked In |

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

Tags:

No Tags on this question yet!