# C program Degree to Radians

• 05-04-2009
Cyberman86
How would you do this c program, I'm a beginner I'm just starting with C, and i can't figure out how to finish the middle part.

Complete the following C program that first reads a, b, c, where a and b are two degrees and c is increment. The program then generates a table of conversions from degrees to radians. Start degrees at a and increment by c until the degree is greater than b.
Recall that we say 180o is equal to π radian.
You can assume that π is 3.14.

Code:

```#include <stdio.h> #define PI 3.14 int main(void) { int a,b,c, degree; /* Enter the start degree, end degree, and increment */ printf("Enter a b c : "); scanf("%d %d %d", &a, &b, &c); for (i=a;i<=b;i=i+c) { printf("degree Radian"); printf(" %d %f", i, i*3.14/180); } system("pause"); /* Exit program. */ return 0; }```
• 05-04-2009
quzah
What is it you can't do? The math?

Quzah.
• 05-04-2009
Cyberman86
Quote:

Originally Posted by quzah
What is it you can't do? The math?

Quzah.

i don't know what to do after this part:

Code:

```for (i=a;i<=b;i=i+c) { printf("degree Radian"); printf(" %d %f", i, i*3.14/180); }```
• 05-04-2009
nonoob
int i;
... and also a "\n" in the printf to generate separate lines. That's about it.

You might want to use your constant PI since you defined it.
• 05-04-2009
ssharish2005
Wel you were almost there. There weren't any much changes. Apart from the few things which nonood had mentioned. Maybe one thing which you should look at is the intendation.

Code:

```#include <stdio.h> #define PI 3.14 int main(void) {   int a,b,c, degree;   int i;     printf("Enter a b c : ");   scanf("%d %d %d", &a, &b, &c);   for (i=a; i<=b; i=i+c)   {       printf("degree Radian: ");       printf("%d - %f\n", i, (i * 3.14) / 180);   }     system("pause");   return 0; }```
-ssharish
• 05-04-2009
BEN10
Quote:

Originally Posted by Cyberman86
How would you do this c program, I'm a beginner I'm just starting with C, and i can't figure out how to finish the middle part.

Complete the following C program that first reads a, b, c, where a and b are two degrees and c is increment. The program then generates a table of conversions from degrees to radians. Start degrees at a and increment by c until the degree is greater than b.
Recall that we say 180o is equal to π radian.
You can assume that π is 3.14.

Code:

```#include <stdio.h> #define PI 3.14 int main(void) { int a,b,c, degree; /* Enter the start degree, end degree, and increment */ printf("Enter a b c : "); scanf("%d %d %d", &a, &b, &c); for (i=a;i<=b;i=i+c) { printf("degree Radian"); printf(" %d %f", i, i*3.14/180); } system("pause"); /* Exit program. */ return 0; }```

Why have you #defined PI if you're not using it?