Solution:
#include < iostream>
#include
using namespace std;
int main()
{
int n, i;
double x, k, product1, product2, product3;
cout «"Enter x and n: ";
cin >> x ;
cin << n ;
i=1;
product1=1;
product2=1;
product3=1;
do
{
k=sin(x)/i;
product1= product1*k;
i++;

}

while(i<=n);

for (i=1;i<=n;i++)
{
k=sin(x)/i;
product2= product2*k;
}

i=1;
while(i<=n)
{

k=sin(x)/i;
product3= product3*k;
i++;.
cout <<"Your product1: " << product1 << endl;
cout <<"Your product2: " <<
product2 << endl;
can't <<"Your product3: " <<
product3 << end;
return 0;
}

Run the program and you will see on the screen of monitor:

Enter x and n: 5
4
Your product1: 0.0352311
Your product2: 0.0352311
Your product3: 0.0352311

3.5 Questions
1. What is the syntax of a for loop in C++?
2. What is the syntax of a do... while loop in C++?
3. What is the syntax of a while loop in C++?
4. How many times is a do while loop guaranteed to loop?
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Copyright © 2024 SCHOLAR.TIPS - All rights reserved.