Part B Input
Part B Input
QUESTION 1
INPUT
#include <iostream>
using namespace std;
int main(void)
{
int number; /* number to be added */
int count; /* count of numbers to be added */
int i; /* loop counter variable */
int total; /* total of the set of numbers */
double average; /* average of the set of numbers */
total = 0; //(a)(iii)
return 0;
}
OUTPUT
PART B
QUESTION 2
INPUT
#include <iostream>
using namespace std;
int main(void)
{
int i, total;
total = 1;
OUTPUT
PART B
QUESTION 3
INPUT
#include <iostream>
using namespace std;
int main(void)
{
int i, total,number;
total = 1;
total *= number;
}
OUTPUT
PART B
QUESTION 4
INPUT
#include <iostream>
using namespace std;
int main(void)
{
int product, number, input;
product = 1;
OUTPUT
PART B
QUESTION 5
INPUT
#include <iostream>
using namespace std;
int main(void)
{
int i, total, number;
char option;
total = 1;
do
{
cout << "Enter number : ";
cin >> number;
total *= number;
cout << "Do you have anymore number?\n";
cin >> option;
OUTPUT
PART B
QUESTION 6
INPUT
#include <iostream>
using namespace std;
int main(void)
{
int product,number,status;
product = 1;
cout << "Enter the numbers to multiply.\n";
cout << "Press cntrl-z when no more number.\n";
while (cin)
{
product *= number;
cout << "Enter next number: ";
cin >> number;
OUTPUT
PART B
QUESTION 7 AND QUESTION 8
INPUT
#include <iostream>
using namespace std;
int main(void)
{
int lower, upper, total, i;
total = 0;
do
{
cout << "Please enter lower limit: ";
cin >> lower;
cout << "Please enter upper limit: ";
cin >> upper;
return 0;
}
OUTPUT
PART B
QUESTION 9
INPUT
#include <iostream>
using namespace std;
int main(void)
{
int max,i, number;
if (i == 1)
max = number;
else
if (max < number)
max = number;
}
return 0;
}
OUTPUT
PART D
QUESTION 1
INPUT
#include <iostream>
using namespace std;
int main(void)
{
int average, number, total=0,counter=0, min,max;
else
{
if (number > max)
max = number;
else if (number < min)
min = number;
}
counter++;
total += number;
cin >> number;
}
cout << "\n You have entered " << counter << "integers\n";
if (counter > 0)
{
cout << "The average is" << (double)total / counter << endl;
cout << "The maximum is" << max << endl;
cout << "The minimum is" << min << endl;
}
return 0;
}
OUTPUT
PART D
QUESTION 2
INPUT
#include<iostream>
#include<iomanip>
using namespace std;
int main(void)
{
int i, j, k;
for (i = 1;i <= 5;i++)
{
for (k = 5 - i;k >= 1;k--)
cout << " ";
for (j = i;j >= 1;j--)
cout << setw(3) << j;
cout << endl;
}
for (i = 4;i >= 51;i--)
{
for (k = 5 - i;k >= 1;k--)
cout << " ";
for (j = i;j >= 1;j--)
cout << setw(3) << j;
cout << endl;
}
return 0;
}
OUTPUT