Question #38937

a) Write a program to find and display the sum of the successive integers 1,2,...100 (Use while loop).
(b) Write a program to find the sum of the following series (Use while loop): 7,11,15,19,23,27,31,35,39,43
(c) Write a program to find the number of integers of the sum of the following integer series 1,3,5,7 ... The total of series is 400. (Use while and break)
(d) Write a program to find sum, product and average of the integer numbers. If the integer number is 0, you terminate the data entry. The average is displayed with 2 decimal format (Use while loop).
1

Expert's answer

2014-02-06T11:54:48-0500
#include<iostream> // for cout and cin
#include <stdlib.h>  // for system
using namespace std;
int main()
{
int sum = 0, i = 0;
while (i < 101)
{
sum += i;
i++;
}
cout << "Sum = " << sum << endl;
system("PAUSE");
return 0;
}
#include<iostream> // for cout and cin
#include <stdlib.h>  // for system
using namespace std;
int main()
{
int sum = 0, i = 7;
while (i < 44)
{
sum += i;
i += 4;
}
cout << "Sum = " << sum << endl;
system("PAUSE");
return 0;
}
#include<iostream> // for cout and cin
#include <stdlib.h>  // for system
using namespace std;
int main()
{
int sum = 0, i = 1, numbers = 0;
while (true)
{
++numbers;
sum += i;
i += 2;
if (numbers == 400) break;
}
cout << "Sum = " << sum << endl;
system("PAUSE");
return 0;
}
#include<iostream> // for cout and cin
#include <stdlib.h> // for system
using namespace std;
int main()
{
int sum = 0, product = 1, numbers = 0, value;
double average = 0.0;
cout << "Input the numbers the end of input 0" << endl;
while (true)
{
cin >> value;
if (value == 0) break;
++numbers;
sum += value;
product *= value;
average = sum / (double)numbers;
}
cout << "Sum = " << sum << endl;
cout << "Product = " << product << endl;
cout << "Average = "; printf("%.2f", average);
cout << endl;
system("PAUSE");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS