Thread: try to do this !!!

1. try to do this !!!

hello all hulls
I want to make a program that displays

1 /*deg=0*/
11 /*degs =1*/
121 /*degs =2*/
1331 /*degs =3*/
14641 /*degs =4/*
.....
deg is a variable

2. Hint:

11**0 = 1
11**1 = 11
11**2 = 121

Where I use "**" to mean "to the power of"

3. I smell homework.

4. thank you laserlight but you must use this
Code:
`pow(11,0);`

5. Originally Posted by enjoy
thank you laserlight but you must use this
Code:
`pow(11,0);`
err...
I was just giving some form of mathematical notation.
Some people use "**", others use "^" (which I normally prefer), but in this case "^" could be confused with XOR.

6. O.K i understand now
thanks again

7. Code:
``` :D
#include "stdio.h"
void main()
{
int i,deg;
scanf("%d",&deg);

for(i=0;i<=deg;i++)
{

printf("%d\n",(11^i));
}
}```
try to compile this !!!!!!
with 0 is ok
but deg>0 ====> wrong

8. The ^ operator is a bitwise exclusive OR, not exponentiation. Your code is also very bad. Here is an improvement that works better.
Code:
```#include <math.h>
#include <stdio.h>

int main()
{
int i,deg;
scanf("%d",&deg);

for(i=0;i<=deg;i++)
{
printf("%.0f\n", pow(11.0,i));
}

return 0;
}```

9. Code:
`thank you neuhart`
but i don't like to use pow
and i have this code
try to optimize him
Code:
```#include "stdio.h"
void main()
{
int i,deg,f=1,k;
scanf("%d",&deg);

for(i=0;i<=deg;i++)
{
if(i==0){f=11;}
else{for(k=0;k<i-1;k++){f=f*(11*11);}}
printf("%d\n",f);
}

}```

10. so i try another code but he don't compile
here is my code
Code:
```#include "stdio.h"
#define n 100
void main()
{
int deg,k,i,j,s,t[n][n];

printf("donnez votre deg\n");
scanf("%d",&deg);

for(j=0;j<deg;j++)
{
for(i=0;i<deg+1;i++)

{
t[j][i]=0;
}
}

for(j=0;j<deg;j++)
{
for(i=0;i<deg+1;i++)
{

if(((i==0)&&(j==0))||((i==1)&&(j<2)))
{

t[j][i]=1;

}

else
{
s=0;
for(k=0;k<deg;k++)
{
s=s+t[j-1][i+k];
}
t[j][i]=s;
}
}
}
for(j=0;j<deg;j++)
{
for(i=0;i<deg+1;i++)
{
if (i==j+1){printf("\n");}
else
{
printf("%d",t[j][i]);
}
}
}
}```

11. Code:
`help me to compile only one please`

12. >but i don't like to use pow
You don't have many choices. You can either use pow, an easier and cleaner approach, or you can do it manually.

>try to optimize him
Why are you trying to optimize code that doesn't even work correctly in the first place?

13. > but i don't like to use pow
So write a function called mypow() which looks almost identical to pow()

And stop using void main()