c program to find pythagorean triples -


int a,b,n;  printf("input natural number n (n<2,100,000,000) : "); scanf("%d",&n);  for(a=1;a<=100;a++)     for(b=1;b<=100;b++)          if(a<b && a*a + b*b == n*n)         {             printf("(%d, %d, %d)\n",a,b,n);         }         /*else         {             printf("impossible \n");         }           */                  return 0; 

if delete 'else' program runs correctly. want make function can check number has pythagorean numbers or not using 'else' paragraph. when put 'else' paragraph in code, result dizzy.... plz me!!

put braces around nested code blocks.

int a, b, n; int impossible = 1;  printf("input natural number n      (n<2,100,000,000) : "); scanf("%d", &n);  (a = 1; <= 100; a++) {     (b = 1; b <= 100; b++) {          if (a < b && * + b * b == n * n) {             printf("(%d, %d, %d)\n", a, b, n);             impossible = 0;         }     } }  if (impossible == 1) printf("impossible \n");  return 0; 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -