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 / kumaran

declaring int i inside for loop is not available in
traditional 'c'

Is This Answer Correct ?    80 Yes 30 No

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

Answer / mariaalex007

Answer is 5..........

Is This Answer Correct ?    114 Yes 77 No

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

Answer / mahfooz

we can not declare loop condition variable in c..we can do
in c++.

Is This Answer Correct ?    38 Yes 20 No

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

Answer / samir isakoski

why shoul have a cout if is c++

buth this is c (printf)

and why cannot daclare a int in the for ciclus

Is This Answer Correct ?    17 Yes 11 No

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

Answer / divya

no output because the for loop is terminated with a semicolon which means the loop will terminate at once.

Is This Answer Correct ?    15 Yes 12 No

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

Answer / radha raman

output=5

Is This Answer Correct ?    5 Yes 3 No

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

Answer / shilpi

it will give 6 as a answer because condition is true inside and then it will increase its value by 1 and the terminate from the loop.

Is This Answer Correct ?    2 Yes 0 No

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

Answer / ricky dobriyal

hi friend i am ricky dobriyal.
if this programe in c then this program produce error
expression syntex error.
if in c++ then it will produce o/p=5

Is This Answer Correct ?    10 Yes 9 No

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

Answer / pramod

if it is in C it displays an error "indicating that "i"
cannot be declared in loop and i as undefined symbol"

if it the case of C++ it displays "5" because C++ supports
dynamic declaration and once declared anywhere in the
program(even in loops) can be used anytime in that program

Is This Answer Correct ?    2 Yes 2 No

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

Answer / marius

if i have

$x=(11,22,33,44,55);
for($i=0;$i<5;$i++)
echo$x[$i]." ";

and we will print this:


11 22 33 44 55

$i=0 => 11
$i<5 => 44
$i++ => 55

ghigamarius@gmail.com

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C C++ Errors Interview Questions

What are the different types of errors in C and when they occur?

4 Answers  


Given that two int variables, total and amount, have been declared, write a loop that reads integers into amount and adds all the non-negative values into total. The loop terminates when a value less than 0 is read into amount. Don't forget to initialize total to 0. Instructor's notes: This problem requires either a while or a do-while loop.

3 Answers  


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,


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  


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,






Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a do...while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total . Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total . Use no variables other than n , k , and total .

3 Answers  


what is the large sustained error signal that eventually cause the controller output to drive to its limit

1 Answers   TCS,


2. A student studying Information Technology at Polytechnic of Namibia is examined by coursework and written examination. Both components of assessment carry a maximum of 50 marks. The following rules are used by examiners in order to pass or fail students. a. A student must score a total of 40% or more in order to pass (total = coursework marks + examination marks) b. A total mark of 39% is moderated to 40% c. Each component must be passed with a minimum mark of 20/50. If a student scores a total of 40% or more but does not achieve the minimum mark in either component he/she is given a technical fail of 39% (this mark is not moderated to 40%) d. Grades are awarded on marks that fall into the following categories. Mark 100-70 69-60 59-50 49-40 39-0 Grade A B C D E Write a program to input the marks for both components (coursework marks out of 50 and examination marks out of 50), out put the final mark and grade after any moderation. [30]

0 Answers  


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).

0 Answers  


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); }

25 Answers   HCL,


#include"stdio.h" #include"conio.h" void main() { int a; printf("\n enter a number:"); scanf("%c\n"); getch(); }

12 Answers   HCL,


How to create a program that lists countries capitals when country is entered? (Terribly sorry, I'm a complete novist to coding with C, am looking for inspiration and general tips on how to code and create this program.)

0 Answers  


Categories