Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


void main()
{
for(int i=0;i<5;i++);
printf("%d",i);
}

What is the output?..

Answers were Sorted based on User's Feedback



void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / gsravya

It will be 0,1,2,3,4

Is This Answer Correct ?    0 Yes 1 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / ish

0
1
2
3
4

Is This Answer Correct ?    2 Yes 4 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / sudeshna

it is a declaration error.
since we declared variable i in the for-loop
and the for-loop is terminated by a semi-colon
so it cannot be accessed outside the for-loop

Is This Answer Correct ?    0 Yes 2 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / suggest

it will report error....
bcoz, integer variable i have scope inside the for loop only....
we cant access it in printf....bcoz for loop have one semicolon

Is This Answer Correct ?    0 Yes 2 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / subash

0
1
2
3
4

Is This Answer Correct ?    0 Yes 2 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / medo

It's 5...if this is in the condition.(case 1)
But if the condition i<=5,the output will be 6.(case 2)
So the hand trace for the cace 1:

Memory__ |_|_|_|___|
i =0 |1|2|3|4|(5)|
i++ =1 |2|3|4|5| - |
it will print 5.

_-_-_-_-_-_-_-_-_-_-_

In the case 2:

Memory__ |_|_|_|_|___|
i =0 |1|2|3|4|5|(6)|
i++ =1 |2|3|4|5|6| - |
it will print 6.

Is This Answer Correct ?    10 Yes 13 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / samir isakoski

If this is a regular c

you cannot put in for loop, non declared integer

it must by declared before the for loop

from 0 to 5

0
1
2
3
4

beacouse it's start from zerro

Is This Answer Correct ?    4 Yes 7 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / shanthi

01234

Is This Answer Correct ?    19 Yes 23 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / sujeesh krishnan

We can't declare a variable in any part of the program
rather than the declaration part.
It doesn't matter whether you use a loop to print or not.
When the statements which are to be executed begins(Here the
looping statement)no declaration is possible in C.
You can do it in C++,C#,java etc.

Is This Answer Correct ?    6 Yes 15 No

void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?....

Answer / kiran123456789

6

Is This Answer Correct ?    4 Yes 21 No

Post New Answer

More C C++ Errors Interview Questions

Assume that the int variables i and j have been declared, and that n has been declared and initialized. Write code that causes a "triangle" of asterisks of size n to be output to the screen. Specifically, n lines should be printed out, the first consisting of a single asterisk, the second consisting of two asterisks, the third consistings of three, etc. The last line should consist of n asterisks. Thus, for example, if n has value 3, the output of your code should be * ** *** You should not output any space characters. Hint: Use a for loop nested inside another for loop.

2 Answers   HCL,


char* f() return "hello:"; void main() {char *str=f(); }

1 Answers  


who was the present cheif governor of reserve bank of india

6 Answers   State Bank Of India SBI,


How to develop a program using C language to convert 8-bit binary values to decimals. TQ

1 Answers   Amazon,


Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has already been declared, use a do...while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j .

2 Answers  


void main() { int i=5; printf("%d",i+++++i); }

14 Answers   HCL,


how tally is useful?

2 Answers  


I'm having trouble with coming up with the correct code. Do I need to put a loop? Please let me know if I'm on the right track and what areas I need to correct. I still don't have a good grasp on this programming stuff. Thanks =) The assignment was to write a program using string functions that accepts a coded value of an item and displays its equivalent tag price. The base of the keys: 0 1 2 3 4 5 6 7 8 9 X C O M P U T E R S Sample I/O Dialogue: Enter coded value: TR.XX Tag Price : 68.00

3 Answers   UCB,


Why are memory errors hard to debug?

1 Answers  


I can not get my C++ program to work right. It is supposed to tell if a word is a palindrome or not, but it only tells thet the word is not a palindrome. And I can't fix it.

1 Answers  


Write a program to accept two strings of Odd lengths. Then take all odd characters from one string and even characters from the other and concatenate and produce a string.

1 Answers  


What is the out put of this programme? int a,b,c,d; printf("Enter Number!\n"); scanf("%d",&a); while(a=!0) { printf("Enter numbers/n"); scanf("%d%d%d",&b,&c,&d); a=a*b*c*d; } printf("thanks!"); getche(); Entering numbers are a=1,b=2,c=3,d=4 b=3,c=4,d=-5 b=3,c=4,d=0

5 Answers   TCS,


Categories