Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

solve it plz Write a complete C++ program that use a while loop to calculate the

ID: 3544882 • Letter: S

Question

solve it plz



Write a complete C++ program that use a while loop to calculate the product of a set of integer input values terminating when a zero is entered. If no integers are input, an appropriate message should be printed, otherwise output the product. Write a segment of C++ code that inputs an integer x and an integer n, The code should use a while loop to calculate xn (x to the power of n) Assume that all integers are positive and do not include an error check. Example: 34 = 3 * 3 * 3 * 3 = 81 Include all declaration, intialization and input of variables. Do not output the results. Write a segment of C++ code that uses one for loop to input 200integers from the keyboard and use a nested-if statement to determine the count of the number of zeros entered. Include all declaration, initialization and input of variables. Do not output the results.

Explanation / Answer

// PROGRAM 1
#include<iostream>
using namespace std;
int main()
{
int prod=1;
int num = 10;
cout << "Enter integer :";
cin >> num;
cout << endl;
while(num!=0)
{
prod = prod*num;
cout << "Enter integer :";
cin >> num;
cout << endl;
}
cout <<"Product of integers is "<< prod << endl;
return 0;
}

// PROGRAM 2
#include<iostream>
using namespace std;
int main()
{
int x,n;
cout <<"Enter value of x and n :";
cin >> x >> n;
cout << endl;
int prod = 1;
for(int i=1; i<=n; i++)
{
prod = prod * x;
}
return 0;
}

// PROGRAM 3
#include<iostream>
using namespace std;
int main()
{
int no_of_zeroes = 0;
int no_of_positives = 0;
int no_of_negatives = 0;
int value;
for(int i=0; i<200; i++)
{
cout << " Enter the value :";
cin >> value;
cout << endl;
if(value>0) no_of_positives++;
else if(value<0) no_of_negatives++;
else no_of_zeroes++;
}

return 0;
}