r/programminghelp • u/psychosquatch42 • Feb 01 '17
Help with a C Loop.
So i have to create program with a loop that outputs the program below, im at a loss for where i should start, any help at all would be appreciated.
#include <stdio.h>
#define PI 3.141593
int main()
{
int degrees = 0;
double radians;
printf("Degrees to Radians \n");
degrees = 0;
radians = degrees*PI/180;
printf("%6i %9.6f \n", degrees, radians);
degrees = 10;
radians = degrees*PI/180;
printf("%6i %9.6f \n", degrees, radians);
.
.
.
degrees = 360;
radians = degrees*PI/180;
printf("%6i %9.6f \n", degrees, radians);
}
3
Upvotes
3
u/[deleted] Feb 01 '17
You want a program that outputs another program?
Just create an array of strings that stores each line. Then, in a for loop std::cout << linearray[i] << std::endl;
Example:
A more C-friendly version: