Find the Output of the Given C Code
What does the following program print? #include int sum,count; void main(void) {< BR> for(count=5;sum+=--count;) printf("%d",sum); } a. The program goes to an infinite loop b. Prints 4791010974 c. Prints 4791001974 d. Prints 5802112085 e. Not sure
Answers
Answered by
1
Answer is (a)
#include <>
int sum, count ;
void main (void)
{
for (count = 5; sum += -- count ; ) printf("%d" , sum ) ;
}
=========
count 0 5 4 3 2 1 0 -1 -2 -3 -4
sum 0 0 4 7 9 10 10 9 7 4 0 STOPS...
Output of the program: 4 7 9 10 10 9 7 4 and program stops..
#include <>
int sum, count ;
void main (void)
{
for (count = 5; sum += -- count ; ) printf("%d" , sum ) ;
}
=========
count 0 5 4 3 2 1 0 -1 -2 -3 -4
sum 0 0 4 7 9 10 10 9 7 4 0 STOPS...
Output of the program: 4 7 9 10 10 9 7 4 and program stops..
Similar questions