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
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 |
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 |
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 |
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 |
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 |
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 |
Write a program using bitwise operators to invert even bits of a given number.
What is volatile, register definition in C
hi any body pls give me company name interview conduct "c" language only
Explain how can type-insensitive macros be created?
C,c++, Java is all are structural oriented or procedure oriented language..?
I have an array of 100 elements. Each element contains some text. i want to: append a star character to the end of every fifth element remove every second character from every tenth element, and… add a line feed (ascii 10) after the 30th character of every array element whose length is greater than 30 characters.
Why do u use # before include in a C Progam?
what is constant pointer?
how to find turn around time in operating system?
If input is 123 then how to print 100 and 20 and 3 seperately?
How can I implement opaque (abstract) data types in C? What's the difference between these two declarations? struct x1 { ... }; typedef struct { ... } x2;
What’s a signal? Explain what do I use signals for?