Argusoft 2nd round programming questions with solution
Argusoft 2nd round programming questions with solution
program 2- write a program to input some number and check whether it belongs to series-1 or not.
series 1 :- 4,2,5,20,40,200,4000,160000,32000000
Solution
#include<stdio.h>
#define N 9
int input[N];
void main()
{
int
i,j,k,l;
printf("Predefined
series is 4,2,5,20,40,200,4000.....\n");
printf("Enter
number Minimum 9 numbers of the series to check\n");
for(i=0;i<N;i++)
{
scanf("%d",&input[i]);
}
//series goes like this 1*3=4
//2*4=5
//3*5=6
int
check;
j=0;
k=2;
l=3;
for(i=0;i<N;i++)
{
if(input[j++]*input[k++]==input[l++])
check=1;
else
check=0;
if(l==N-1)
break;
}
if(check)
printf("\nInputted
series belongs to predefined series");
else
printf("\nInputted
series not belongs to predefined series");
}
Comments
Post a Comment