#include<stdio.h>
#include<math.h>
void main()
{
int a=1,b=1,c,n;
printf("enter the no for which u want the term");
scanf("%d",&n);
while(a<n)
a=a+pow(2,b++);
c=pow(2,--b);
if((c<=n)&&(n<=a))
printf("\n%d",c);
}
NOTE- i have compiled this program in codeblocks if u do it in turbo c++ use conio.h header file in the beginning and getch() a the last.
No comments:
Post a Comment