+ 2
What is the output? unsigned int i; int count=0; for (i=0; i<10;i--) cout++; printf("%d",count);
Cprog
7 Respuestas
+ 11
Output is 1
because i is unsigned
https://code.sololearn.com/c1vbAu60AH9V/?ref=app
+ 6
The for loop has some issue if it was supposed to increment `count` 10 times.
The loop's step should be incremented otherwise the program just step through the loop's body once and when the `i` decremented for the first time, the value will wrap around and it'll be 4294967295 which breaks the loop due to `i < 10` condition.
Test:
#include <stdio.h>
int main() {
unsigned int i;
int count = 0;
for (i = 0; i < 10; i--) {
count++;
printf("i = %u, count = %d\n", i, count);
}
printf("i = %u, count = %d", i, count);
}
Output:
i = 0, count = 1
i = 4294967295, count = 1
0
1
0
Many errors in ur program
0
I think it must give error as cout must be count
0
Ur prgm will generate many errors
0
beacuse loop decremant to decreased fidelity