C language prelab Write a declaration statement for two doub
C language prelab
Write a declaration statement for two double variables, named x, and xsum. Write a declaration statement for two integers, named n, and n_count. write the syntax for a for loop that executes while the counting variable increases from 0 to 4, with increments of 1. (use n_count as the counting variable and n_countSolution
#include \"stdio.h\"
int main(void) {
// declaration of x and x_sum
double x,x_sum=0;
// declaration of n and n_count
int n=5,n_count,k=0;
//declaration of wish
char wish;
// for loop 0-4
for(n_count=0;n_count<5;n_count++){
printf(\"%d \",n_count);
}
printf(\"\ \");
// for loop 0 to n-1
for(n_count=0;n_count<n;n_count++){
printf(\"%d \",n_count);
}
printf(\"\ \");
// do while loop for wish
do{
printf(\"Do you wish to input another set of data?\");
scanf(\" %c\",&wish);
}while(wish==\'y\');
// while loop for k
while(k<1 || k>5){
printf(\"Enter k value\");
scanf(\"%d\",&k);
}
printf(\"Enter number of elements:\");
scanf(\"%d\",&n);
// for loop for calculation of sum of values entered.
for(n_count=0;n_count<n;n_count++){
printf(\"Enter new number x:\");
scanf(\"%lf\",&x);
x_sum += x;
}
printf(\"Sum:%lf\ \",x_sum);
return 0;
}
/* sample output
*/
