solve it plz Write a complete C++ program that use a while loop to calculate the
ID: 3544882 • Letter: S
Question
solve it plz
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;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.