Write a program to generate the first n terms in the series --- 4,5,9,18,34,...
Answers
Answered by
3
here is your answer....
Attachments:
Answered by
0
C++ program for generating first n terms in the series of 4, 5, 9, 18, 34.
#include <iostream.h>
#include <conio.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
void main ()
{
int a = 4, b = 5, c = 34, i, n, sub = 16;
scanf("%d", &n);
if (n>6)
{
for (i=0; i<n-6; i++)
{
sub= sub*2
a=a+sub;
b=b+(sub/2);
}
}
cout <<"%d%d, a, b:<<endl;
for (i=0; i<n-2; i++)
{
sub= sub/2
b=b+sub;
printf("%d".b);
}
return 0;
getch();
}
Similar questions
History,
8 months ago
Chemistry,
8 months ago
Computer Science,
1 year ago
English,
1 year ago
English,
1 year ago