This is supposed to find the pythagorean triples to the number 1000. But the
program doesn't outputanything it just runs and ends. What did I do wrong?(And
now thta i look at the code i could just put a goto start;)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
include <stdio.h>
include <stdlib.h>
include <math.h>
include <dos.h>
int main(){
float a, b, c, i=0;
for(a =1;a <= 1000; a=a+0.1){
for(b=1; b>0; b=b+0.1){
if(i=1){
i=0;
break;
}
for(c; c>0; c+=0.1){
if((cc)==((aa)+(b*b))){
printf("%f\n", c);
sleep(2);
i++;
break;
}
}
}
}
system("PAUSE"); return 0; }
This is supposed to find the pythagorean triples to the number 1000. But the
program doesn't outputanything it just runs and ends. What did I do wrong?(And
now thta i look at the code i could just put a goto start;)
changed dos.h to windows.h and sleep into upper case
and the 2 in Sleep to 2000
The variable c never gets initialised. Initialise it in the first
expression of the for statement thus:
for( c = 0; c > 0; c += 0.1 )
Note that this code does not depend on math.h.