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

Explain how do you generate random numbers in c?

0 Answers  


What is the difference between break and continue?

0 Answers  


how to write a cprogram yo get output in the form * *** ***** ******* ********* ******* ***** *** *

3 Answers  


difference between my-strcpy and strcpy ?

3 Answers   Geometric Software, IIM, Infosys,


What are integer variable, floating-point variable and character variable?

0 Answers  






what is the diff b/w static and non static variables in C. Give some examples plz.

3 Answers   Wipro,


how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?

0 Answers   Gopaljee, TCS,


How does normalization of huge pointer works?

0 Answers  


List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.

0 Answers   Ignou,


18)struct base {int a,b; base(); int virtual function1(); } struct derv1:base{ int b,c,d; derv1() int virtual function1(); } struct derv2 : base {int a,e; } base::base() { a=2;b=3; } derv1::derv1(){ b=5; c=10;d=11;} base::function1() {return(100); } derv1::function1() { return(200); } main() base ba; derv1 d1,d2; printf("%d %d",d1.a,d1.b) o/p is a)a=2;b=3; b)a=3; b=2; c)a=5; b=10; d)none 19) for the above program answer the following q's main() base da; derv1 d1; derv2 d2; printf("%d %d %d",da.function1(),d1.function1(),d2.function1 ()); o/p is a)100,200,200; b)200,100,200; c)200,200,100; d)none 20)struct { int x; int y; }abc; you can not access x by the following 1)abc-->x; 2)abc[0]-->x; abc.x; (abc)-->x; a)1,2,3 b)2&3 c)1&2 d)1,3,4

1 Answers  


Sir i want e-notes of C languge of BAlaguruswami book i.e scanned or pdf file of balaguruswamy book on c language.PLEASE SEND ME on my mail id ajit_kolhe@rediff.com

8 Answers  


marge linklist

0 Answers   HCL,


Categories