I find the maximum value of a by charsimple addition and testing when the number is negative:
#include<stdio.h>
int main(){
char c = 1;
while(c + 1 > 0)
++c;
printf("Max c = %d\n",(int)c);
return 0;
}
The loop test whileruns forward, so the first time a c+1negative one is interrupted, and we print the value c. However, programming outputs a negative number!
Why does this program not output 127?
source
share