Hi friends, I'm a newbie into C/C++ world. So i hope you can help me with this question. I need to do a program using do..while statement in C languages to produce the following output
0 1
1 4
2 16
3 64
4 256
5 1024
6 4096
i have done something with this program and i only manage to get the following output
0 0
1 1
2 4
5 25
using this program :
[code=c]
#include<stdio. h>
int x=0;
int x2, x;
void main()
{
do
{
x2 = x;
x = x*x;
printf("\n%d %d", x2, x);
x += 1;
} while (x<=21);
getch();
}
[/code]
can anyone help me?
0 1
1 4
2 16
3 64
4 256
5 1024
6 4096
i have done something with this program and i only manage to get the following output
0 0
1 1
2 4
5 25
using this program :
[code=c]
#include<stdio. h>
int x=0;
int x2, x;
void main()
{
do
{
x2 = x;
x = x*x;
printf("\n%d %d", x2, x);
x += 1;
} while (x<=21);
getch();
}
[/code]
can anyone help me?
Comment