What is the output of the program given below

#include<stdio.h>
main()
{
char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}




Answers were Sorted based on User's Feedback



What is the output of the program given below #include<stdio.h> main() { ..

Answer / sh college,thevara

-128

Is This Answer Correct ?    30 Yes 8 No

What is the output of the program given below #include<stdio.h> main() { ..

Answer / sharan

#include<stdio.h>
main()
{
char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}

Here the CATCH is semicolon after for
so maximum positive value for the signed char is 127.
Hence it loops 127 times after that value of i wraps to
negative value that is -128.

Thus it prints -128.

Is This Answer Correct ?    10 Yes 1 No

What is the output of the program given below #include<stdio.h> main() { ..

Answer / rani

output is

-128

Is This Answer Correct ?    10 Yes 3 No




What is the output of the program given below #include<stdio.h> main() { ..

Answer / karan

it will display the garbage value bcoz there is semicolon
at end of the for loop which will be
-128

Is This Answer Correct ?    3 Yes 0 No

What is the output of the program given below #include<stdio.h> main() { ..

Answer / gajanandon

after for there is semicolon...means empty statement. So no
effect of printf.
so for runs till i (char value) increments in positive
direction and terminates once it exceeds 127 (char
limitation).
Hence finally printf will execute and then prints -128.

Is This Answer Correct ?    3 Yes 0 No

What is the output of the program given below #include<stdio.h> main() { ..

Answer / stuti

1

Is This Answer Correct ?    2 Yes 0 No

What is the output of the program given below #include<stdio.h> main() { ..

Answer / aryan

-128

Is This Answer Correct ?    1 Yes 0 No

What is the output of the program given below #include<stdio.h> main() { ..

Answer / prasanna kumar [cse dept. kln

i think the program will give the output as 0 or null....
because i=0 is in int datatype but in this program it is
declared as character datatype so it will give the output as
0 or null and it will goes for only one time after wards it
will incremented and goes infinitely....

Is This Answer Correct ?    0 Yes 0 No

What is the output of the program given below #include<stdio.h> main() { ..

Answer / akash dhal

initialized with 0
in for loop ist time condition satisfied so print 0,like
this 127 will be printed .as it is a signed no. so 127+1 is
-128 so condition false come out of the loop.

Is This Answer Correct ?    0 Yes 0 No

What is the output of the program given below #include<stdio.h> main() { ..

Answer / vennila

*
**
***
****

Is This Answer Correct ?    0 Yes 0 No

Post New Answer



More C Interview Questions

what is op? for(c=0;c=1000;c++) printf("%c",c);

21 Answers   Trigent,


Write a program to generate prime factors of a given integer?

2 Answers  


c language interview questions & answer

0 Answers  


hat is a pointer?

4 Answers   Assurgent,


difference between the array and linked list general difference related to memory

2 Answers  






There is a mobile keypad with numbers 0-9 and alphabets on it. take input of 7 keys and then form a word from the alphabets present on those keys.

0 Answers  


what is the difference between these initializations? Char a[]=”string”; Char *p=”literal”; Does *p++ increment p, or what it points to?

4 Answers  


write a c program to find reminder and quotient if one number is divided by other.to code this program don't use more than 2 variables

2 Answers   TCS,


out put of printf(“%d”,printf(ram));

5 Answers  


write a c program to find largest number in matrix(in each row,each column, diagonally, and in the whole matrix)? Its urgent.

2 Answers  


c program for searching a student details among 10 student details

0 Answers  


two progs are given. one starts counting frm 0 to MAX and the other stars frm MAX to 0. which one executes fast.

5 Answers   Verifone,






Categories