Académique Documents
Professionnel Documents
Culture Documents
PAttern
Question 1 printf(“%d”,x);
}
Find the nth term of the series. }
int main()
1,1,2,3,4,9,8,27,16,81,32,243,…. {
int n;
#include<stdio.h> scanf(“%d”,&n);
#include<math.h> if(n%2==0)
int three(n) three(n/2);
{ else
int x,i; two(n/2+1);
for(i=0;i<100;i++) }
{
x=pow(3,i); Question – 2
if(i==n)
printf(“%d”,x); Link to this Question
}
} Consider the following
int two(n) series: 1,1,2,3,4,9,8,27,16,81,32,243,
{ 64,729,128,2187…
int x,i;
for(i=0;i<100;i++) This series is a mixture of 2 series –
{ all the odd terms in this series form a
x=pow(2,i); geometric series and all the even
if(i==n) terms form yet another geometric
series. Write a program to find the return 0;
Nth term in the series. }
2.term(2)=2 printf(“2”);
}
else count=1;
{ while(a[i]==a[i+1])
Question 8
aaaabbBccdee change to
a4b2B1c2d1e2
int main()
char a[100];
int i,count=0;
scanf(“%s”,a);
for(i=0;a[i]!=’\0′;i++)