Write a program to generate the first 'n' terms of the following series 0.5, 1.5, 4.5, 13.5, ... Input Format: The input is an integer 'n' which denotes the number of terms to be printed in the series ...?"
Answers
Answered by
5
Answer:
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
float a=0.5;
for(int i=1;i<=n;i++)
{
cout<<a<<" ";
a=a*3;
}
return 0;
}
Explanation:
Answered by
0
Answer:
#include <iostream>
#include <cmath>
int main()
{
int n;
std::cin>>n;
double r=0.5;
for(int i=0;i<n;i++)
{
if(i==0)
{
std::cout<<r;
continue;
}
else
{
double t=pow(3,i-1);
double x=t+r;
r=x;
std::cout<<" "<<x;
}
}
}
Explanation:
In the above program some header files and included and for loop has been used with the suitable condition.
The output of the code will be the series 0.5, 1.5, 4.5, 13.5, up to the number of terms entered by the user.
To learn more about program refer:
brainly.in/question/16786741
brainly.in/question/16786741
#SPJ2
Similar questions
Science,
5 months ago
Math,
5 months ago
Social Sciences,
10 months ago
Geography,
1 year ago
Math,
1 year ago