Answer the questions below in a typed document numbered appr

Answer the questions below in a typed document, numbered appropriately. Print out this sheet as a cover page. Bring the completed assignment to your next lab class. 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_count

Solution

1)
double x,xsum;

2)
int n,n_count;

3)
for(n_count=0;n_count<5;n_count++)
{
....
}

4)
for(n_count=0;n_count<n;n_count++)
{
....
}

5) //Assuming character \"response\" is already declared
do{
....
}while(response==\'y\' || response==\'Y\');

6)   //Assuming integer variable k is already declared
while(k<1 || k>5)
{
....
}

7)
#include <stdio.h>
int main()
{
   double x,xsum=0;
   int n;
   printf(\"Enter total number of elements\");
scanf(\"%d \", &n);
   for(int i=0;i<n;i++)
   {
       printf(\"Enter the number \");       //Input statement
       scanf(\"%d \", &x);
       xsum+=x;
   }  
   printf(\"Sum of all the elements = %d\", xsum);           //Output statement
return 0;
}

 Answer the questions below in a typed document, numbered appropriately. Print out this sheet as a cover page. Bring the completed assignment to your next lab c

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site