Unsigned char c;
for ( c=0;c!=256;c++2)
printf("%d",c);

No. of times the loop is executed ?

Answers were Sorted based on User's Feedback



Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times t..

Answer / subbu

instead of "c++2" if there is "c++" it will not give any
errors. output will be continuosly for infinite number of
times.

Is This Answer Correct ?    17 Yes 0 No

Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times t..

Answer / shalabh

This will be an infinite loop as the value of unsigned char
cannot exceed 255....c++2 can be errornous..but the value
of unsigned char cannot go beyond 255

Is This Answer Correct ?    5 Yes 1 No

Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times t..

Answer / manishsoni

It produce compile time error becoz the statement c++2 is
not allowed here.

if this statement is written as c+=2,then it will give us an
infinite loop between
0--->254----->0---->254...
because it check simply c!=256(mean c is not equal to
256,mean it simply it didnot print the value at 256,that
mean it did not print 256...after 254...and print 0)
------------------------------------------------------------
No. of times the loop is executed ?
------------------------------------------------------------
loop will execute 128 times becoz:
the loop is increased each time by 2 and loop is execute
254 time without zero so
254/2=127
127+1(zero)=128;
so the loop is execute 128 times....
BY:ManisH SonI(MoNu)

Is This Answer Correct ?    4 Yes 1 No

Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times t..

Answer / sundeep

First of all the code returns compile time error....bcoz
of "c++2",and c!=256 becoz unsigned char takes just 255
bytes..........and exceeding that results in compile time
error........

Is This Answer Correct ?    6 Yes 4 No

Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times t..

Answer / manish soni

IT SHOW ACTUAL O/P.
main()
{
int c;
int i=1;
for ( c=0;c!=256;c+=2)
{
printf("%d=%d\n",i,c);
i++;
}
getch();
}

MANISH SONI
[GYAN CORPORATION,CHANDIGARH]

Is This Answer Correct ?    1 Yes 0 No

Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times t..

Answer / prabu

infinite loop executed

Is This Answer Correct ?    0 Yes 0 No

Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times t..

Answer / manishsoni

The program is as:
------------------------------------------------------------
#include<stdio.h>
#include<conio.h>
int main()
{
unsigned char c;
for(c=0;c!=256;c++2)
{
printf("%d",c);
printf("\n");
}

getch();
}

Is This Answer Correct ?    0 Yes 1 No

Unsigned char c; for ( c=0;c!=256;c++2) printf("%d",c); No. of times t..

Answer / sanjeev

this loop is executed at 254 times.

Is This Answer Correct ?    2 Yes 7 No

Post New Answer

More C Interview Questions

read the folllowing code # define MAX 100 # define MIN 100 .... .... if(x>MAX) x=1; else if(x<MIN) x=-1; x=50; if the initial value of x=200,what is the vlaue after executing this code? a.200 b.1 c.-1 d.50

4 Answers   TCS,


in b=6.6/a+(2*a+(3*c)/a*d)/(2/n); which operation will be performed first a) 6.6/a b) 2*a c) 3*c d) 2/n

1 Answers  


What is meant by int fun const(int a, int b) { .... ... }

1 Answers  


Differentiate between functions getch() and getche().

0 Answers  


What is a stream?

0 Answers  


Explain how can you tell whether a program was compiled using c versus c++?

0 Answers  


How can I find the day of the week given the date?

0 Answers  


What is the advantage of using #define to declare a constant?

0 Answers   Agilent, ZS Associates,


What's wrong with the call "fopen ("c:\newdir\file.dat", "r")"?

1 Answers  


write a function to find whether a string is palindrome or not and how many palindrome this string contain?

2 Answers   Aptech,


#include<stdio.h> #include<conio.h> int main() { int a[4][4]={{5,7,5,9}, {4,6,3,1}, {2,9,0,6}}; int *p; int (*q)[4]; p=(int*)a; q=a; printf("\n%u%u",p,q); p++; q++; printf("\n%u%u",p,q); getch(); return 0; } what is the meaning of this program?

2 Answers  


How can I read a directory in a c program?

1 Answers   CSC,


Categories