I don't think that it is important to say what the topic is. I will just mention that I want to print i
and a
along with the 1
.
Here is my code:
int riz(int k,int *p,int *q)
{
int i;
int a;
for (i = 1; i <= sqrt((double)k) + 1; i++)
{
for (a = 1 ; a <= sqrt((double)k) + 1; a++)
{
if (a*a+i*i == k)
{
p=&a;
*p=a;
q=&i;
*q=i;
return 1;
}
}
}
return 0;
}
int main(int argc, char *argv[])
{
int p;
int q;
int a;
printf("Give me a number or type 0 to exit \n");
scanf("%d", &a);
if (a == 0)
return 0;
printf("%d\n", riz(a, &p, &q));
while (a != 0)
{
printf("Give me a number or type 0 to exit \n");
scanf("%d", &a);
if (a == 0)
return 0;
printf("%d\n", riz(a, &p, &q));
}
return 0;
}
I've read other questions which are related to this but still I can't figure out why I can't print i
and a
.