What is the output of the following program? Write your answer with explanation.
Attachments:
Answers
Answered by
0
Answer:
Predict the output of below programs.
Question 1
#include<stdio.h>
int main()
{
int n;
for(n = 7; n!=0; n--)
printf("n = %d", n--);
getchar();
return 0;
}
Output:Above program goes in infinite loop because n is never zero when loop condition (n != 0) is checked.
Question 2
#include<stdio.h>
int main()
{
printf("%x", -1<<1);
getchar();
return 0;
}
Output is dependent on the compiler. For 32 bit compiler it would be fffffffe and for 16 bit it would be fffe.
Similar questions