#include<stdio.h>
#include<conio.h>
int main()
{
int n,x; // declare the variable
long double i=2; //declare the variable of long double type
clrscr();
printf("Enter the number : ");
scanf("%d",&n);
printf("\n");
x=1;
while(x<=n) // loop will be execute till the value of x I less or equal n
{
printf("%.2Lf\n",i); // print the value of I upto 2 decimals only
x++;
i*=i;
}
getch();
return 0;
}
Output:
Enter the number : 4
2.00
4.00
16.00
256.00
#include<conio.h>
int main()
{
int n,x; // declare the variable
long double i=2; //declare the variable of long double type
clrscr();
printf("Enter the number : ");
scanf("%d",&n);
printf("\n");
x=1;
while(x<=n) // loop will be execute till the value of x I less or equal n
{
printf("%.2Lf\n",i); // print the value of I upto 2 decimals only
x++;
i*=i;
}
getch();
return 0;
}
Output:
Enter the number : 4
2.00
4.00
16.00
256.00
/**/
ReplyDelete#include
#include
void main()
{
int i,n;
long double a;
clrscr();
printf("\nEnter Any Number :");
scanf("%d",&n);
a=2;
printf("\n");
i=1;
while(i<n)
{
printf("%Lg ,",a);
a*=a;
i++;
}
printf("%Lg",a);
getch();
}
Enter the number : 4
2
4
16
256