void main()
{
for(int i=0;i<5;i++);
printf("%d",i);
}
What is the output?..
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
How to upgrade LOOP environment, I just mean, how can i make loop statement editable ? I just try some program using loop statement and checking it in multiple compilers. Every compiler showing different output, what's the wrong ? is it a compiler based problem, or loop based problem, tell me why ? and what will be the debugging process, for this kind of problem ?
how to convert decimal to binary in c using while loop without using array
50 Answers Apple, Aptech, Arwen Tech, BCS, C2D Software, CEC,
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
how tally is useful?
WHAT WILL BE THE OUTPUT OF THE FOLLOWING QUESTION void main() { int x=4,y=3,z; z=x-- -y; printf("%d%d%d",x,y,z); }
what is syntax error?
Given that two int variables, total and amount , have been declared, write a sequence of statements that: initializes total to 0 reads three values into amount , one at a time. After each value is read in to amount , it is added to the value in total (that is, total is incremented by the value in amount ). Instructor's notes: If you use a loop, it must be a for loop. And if you use a loop control variable for counting, you must declare it.
How to develop a program using C language to convert 8-bit binary values to decimals. TQ
void main() { int i=7; printf("N= %*d",i,i); }
Display this kind of output on screen. 1 0 1 1 0 1 3. Display this kind of output on screen. 1 1 0 1 0 1 4. Display this kind of output on screen. 1 1 0 1 0 1 5.Display this kind of output on screen. 1 2 3 4 5 6 7 8 9 10
What is probability to guarantee that the task a programmer is going to create will be created and be able to run on a particular system (RTOS/GPOS).
what is run time error?