In: Computer Science
#include <stdio.h>
int main(void) {
int input = -1;
double average = 0.0;
/* Use this for your input */
scanf("%d", &input);
/* This is the only output you need */
printf("%.1lf", average);
return 0;
}
Please write a C coding program (make it simple coding) that find the average of sequence integer. when user enter integers, once at a time. Also, If the user enters 0 (zero), the code will calculates the average and then prints it, and then exits.
#include <stdio.h> int main(void) { int input = -1; double average = 0.0; int count = 0; do { scanf("%d", &input); if(input != 0) { count++; average += input; } } while(input != 0); if(count != 0) { average = average/count; } /* This is the only output you need */ printf("%.1lf", average); return 0; }
************************************************** Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.