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

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -