Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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 ?    31 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 ?    11 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 ?    11 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 ?    2 Yes 0 No

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

Answer / rekha

It will print 0 to 127

Is This Answer Correct ?    6 Yes 6 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

Post New Answer



More C Interview Questions

What is use of null pointer in c?

0 Answers  


write a fuction for accepting and replacing lowercase letter to'Z' with out using inline function.

5 Answers   Temenos,


Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors

3 Answers  


write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...

0 Answers  


What is the use of function overloading in C?

0 Answers   Ittiam Systems,






Why doesnt this code work?

0 Answers  


What is a list in c?

0 Answers  


what is c programming?

3 Answers   TCS,


What is a macro?

0 Answers  


which operator having highest precedence? a.)+ b.)++ c.)= d.)%

4 Answers  


How do you write a program which produces its own source code as output?

0 Answers  


An array name contains base address of the array. Can we change the base address of the array?

4 Answers   NMIMS, Wipro,






Categories