Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a complete C program, from the #includes to the closing } that compiles an

ID: 3644663 • Letter: W

Question

write a complete C program, from the #includes to the closing } that compiles and runs as written. The program will input something with a prompt, do some calculation, and output something with explanatory text. For example,



0A. Write a complete C program that inputs (with a prompt) a non-negative integer n. Output the sum of the digits of the square of n, with explanatory text.

An example run of your program (with the user input in boldface) might go as

#: 123

sum is 18

(because the square of 123 is 15129)



0B. Write a complete C program that inputs (with a prompt) the radius of a sphere and length of a side of a regular hexagon. Output the area of the hexagon. According to my geometry book, the area of a regular hexagon is given by the formula


An example run of your program might go as

side: 1.1

area is 3.143672



0C. Write a complete C program that inputs ( with a prompt) as many positive floating-point values as the user wants to type, followed by 0. Output, with explanatory text, the average of the positive numbers.

An example run of your program might go as

gimme #

Explanation / Answer

#include int main() /* Function main begins program execution */ { int integern; /* Integer n to be evaluated */ int counter; /* Integer entered */ int result; /* Factorial of integer */ int start; /* beginning of execution */ start: printf( "Input value to compute factorial for: " ); /* Prompt input value for n */ scanf( "%d", &integern ); /* Obtained integer value */ /* Initialization phase */ result = 1; /* Intitialize result */ counter = integern; /* Initialize loop counter */ /* Processing phase */ while ( counter > 1 ) { /* Loop until counter equals 1 */ result = result * counter; /* Multiply counter to result */ --counter; /* decrement counter */ } /* If integer greater or 0, print "factorial is equal to: %d" */ if ( integern >= 0 ) printf( " Factorial is equal to:%d ", result ); /* otherwise, print "Input value not valid." */ else{ printf( " Error: Input value not valid. "); goto start; } return 0; /* Indicate program ended successfully */ } b)#include int main() { float r ; printf (" Enter the radius of the circle : ") ; scanf("%f",r) ; printf (" The area of the circle = %f ",3.14*r*r) ; return 0 ; }