Question

22. (6 points) Determine the output for the following coe # include < stdio.h > int main(void) ( int z 1, total -0, y printf(d , x) ) //end-for printf(The total %d\n, total) ) //end-main
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

int main(void) {

int x = 1, total = 0, y;

for (x = 1; x < 5; x++) {

y = x * x;

printf("%d\n", y);

printf("%d", x);

} // end-for

printf("The total = %d\n", total);

return 0;

} // end main

/*

The above code will output:

1

14

29

316

4The total = 0

Output explained:

in the for loop in every loop getting the square value of x and assigning it to y

so in first time x = 1 so it x=1 and y =1 and in second loop

y = 2*2 that is 4 and and vaule of x is 2 so same way it will run unless its value is less than 5

as value of total is not updating so it will remain as 0

*/

Add a comment
Know the answer?
Add Answer to:
22. (6 points) Determine the output for the following coe # include < stdio.h > int...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT