#include<iostream>
#include <stdlib.h>
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>
#include <stdlib.h>
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>
#include <stdlib.h>
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>
#include <stdlib.h>
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;
}
Comments