What will be the output of the program, if a short int is 2 bytes wide?#include<stdio.h>int main(){ short int i = 0; for(i<=5 && i>=-1; ++i; i>0) printf("%u,", i); return 0;}1 ... 65535Expression syntax errorNo output0, 1, 2, 3, 4, 5
Question
What will be the output of the program, if a short int is 2 bytes wide?#include<stdio.h>int main(){ short int i = 0; for(i<=5 && i>=-1; ++i; i>0) printf("%u,", i); return 0;}1 ... 65535Expression syntax errorNo output0, 1, 2, 3, 4, 5
Solution
The code you've provided has a syntax error. The correct syntax for a for loop in C is for(initialization; condition; increment/decrement). However, in your code, you've written for(i<=5 && i>=-1; ++i; i>0), which is not the correct syntax.
If you want to print numbers from 0 to 5, you can modify your code like this:
#include<stdio.h>
int main(){
short int i = 0;
for(i=0; i<=5; i++)
printf("%u,", i);
return 0;
}
This will output: 0, 1, 2, 3, 4, 5,
Similar Questions
What will be the output of the program, if a short int is 2 bytes wide?#include<stdio.h>int main(){ short int i = 0; for(i<=5 && i>=-1; ++i; i>0) printf("%u,", i); return 0;}1 ... 65535Expression syntax errorNo output0, 1, 2, 3, 4, 5
What is the output of this program? Integer i = new Integer(257); byte x = i.byteValue(); System.out.print(x);Select one:25710256
Which will be the output? #include<stdio.h> int main () { char i=65; printf (“%d”, sizeof(i)); return 0; } 4 8 2 1
What will be the output of the given program? int main(){void * p;p = calloc(10,sizeof(int));cout<<"The number of bytes reserved are " << 10*sizeof(int);free (p);return 0;}
What will be the output of the following program in Python?print( not 2 < 4)
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.