farouk nuseibeh February 2016

How can i print the number under each stage and have it come out neat?

#include <stdio.h>


int main(void) {
    int a, b, c;

  printf("stage A   stage B  Hypotenuse\n");
    for (a=1; a<1000; a++){

        for(b=1;b<1000;b++){

            for(c=1;c<1000;c++){

                if(a*a+b*b==c*c){

                    printf("     %d         %d        %d\n",a,b,c);

                }
            }
        }
    }

This is what i did, how can i make each one come under the stage in a row?
}

Answers


Marlene February 2016

Instead of '%d' you can put '%10d' (any number you want) to make a field that many digits wide.

Post Status

Asked in February 2016
Viewed 1,641 times
Voted 5
Answered 1 times

Search




Leave an answer