Can someone help me with this c program no matter what i do it just wont run and compile its suppose to have an output exactly llike the example output.I keep getting error codes during the compiling I just dont know what to do . Error Codes given after trying to compile : In function ‘main’: trigTable.c:24:15: error: ‘increment’ undeclared (first use in this function) scanf("%d", &increment);} ^ trigTable.c:24:15: note: each undeclared identifier is reported only once for each function it appears in trigTable.c: At top level: trigTable.c:25:9: error: expected declaration specifiers or ‘...’ before string constant printf("\t---\tTRIGONOMETRIC TABLE\t---\t\n\n"); ^ trigTable.c:26:9: error: expected declaration specifiers or ‘...’ before string constant printf("Degrees\t\tRadians\t\tSine\t\tCosine\t\tTangent\n"); ^ trigTable.c:27:9: error: expected declaration specifiers or ‘...’ before string constant printf("-------\t\t------\t\t----\t\t------\t\t-------\n"); ^ trigTable.c:28:2: error: expected identifier or ‘(’ before ‘for’ for(int degree = 0; degree <= 360; degree += degrees){ ^ trigTable.c:28:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<=’ token for(int degree = 0; degree <= 360; degree += degrees){ ^ trigTable.c:28:44: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘+=’ token for(int degree = 0; degree <= 360; degree += degrees){ ^ trigTable.c:40:9: error: expected declaration specifiers or ‘...’ before string constant printf("\nThank you for using trigTable. Bye."); ^ trigTable.c:41:2: error: expected identifier or ‘(’ before ‘return’ return 0; ^ trigTable.c:42:1: error: expected identifier or ‘(’ before ‘}’ token } ^ Example of Output Welcome to trigTable. This program will print a table of trigonometric values from 0 to 360 degrees in increments selected by the user. Please the select the number of degrees for the increment: 30 --- TRIGONOMETRIC TABLE --- Degrees Radians sine cosine tangent ------- ------- ------ ------ --------- 0 0.0000 0.0000 1.0000 0.00000 30 0.5236 0.5000 0.8660 0.57735 60 1.0472 0.8660 0.5000 1.73205 90 1.5708 1.0000 0.0000 infinity 120 2.0944 0.8660 -0.5000 -1.73205 150 2.6180 0.5000 -0.8660 -0.57735 180 3.1416 0.0000 -1.0000 -0.00000 210 3.6652 -0.5000 -0.8660 0.57735 240 4.1888 -0.8660 -0.5000 1.73205 270 4.7124 -1.0000 -0.0000 infinity 300 5.2360 -0.8660 0.5000 -1.73205 330 5.7596 -0.5000 0.8660 -0.57735 360 6.2832 -0.0000 1.0000 -0.00000 Thank you for using trigTable. Bye! CODE THAT WONT COMPILE: #include #include #define THRESHOLD 1e-10 int main(){ int increments; printf("Welcome to trigTable.\n"); printf("This program will print a table of trigonometric values\n"); printf("from 0 to 360 degrees in increments selected by the user.\n\n"); printf("Please the select the number of degrees for the increment: "); scanf("%d", &increment);} printf("\t---\tTRIGONOMETRIC TABLE\t---\t\n\n"); printf("Degrees\t\tRadians\t\tSine\t\tCosine\t\tTangent\n"); printf("-------\t\t------\t\t----\t\t------\t\t-------\n"); for(int degree = 0; degree <= 360; degree += degrees){ double radians = degree * M_PI / 180; double sine = sin(radian); double cosine = cos(radian); double tangent = tan(radian); printf("%d\t\t%.4f\t\t%.4f\t\t%.4f\t\t", degree, radian, sine, cosine); if (fabs(cosine) < THRESHOLD){ printf("infinity\n"); }else{ printf("%.5f\n", tangent); } } printf("\nThank you for using trigTable. Bye."); return 0; }
Can someone help me with this c program no matter what i do it just wont run and compile its suppose to have an output exactly llike the example output.I keep getting error codes during the compiling I just dont know what to do .
Error Codes given after trying to compile :
In function ‘main’:
trigTable.c:24:15: error: ‘increment’ undeclared (first use in this function)
scanf("%d", &increment);}
^
trigTable.c:24:15: note: each undeclared identifier is reported only once for each function it appears in
trigTable.c: At top level:
trigTable.c:25:9: error: expected declaration specifiers or ‘...’ before string constant
printf("\t---\tTRIGONOMETRIC TABLE\t---\t\n\n");
^
trigTable.c:26:9: error: expected declaration specifiers or ‘...’ before string constant
printf("Degrees\t\tRadians\t\tSine\t\tCosine\t\tTangent\n");
^
trigTable.c:27:9: error: expected declaration specifiers or ‘...’ before string constant
printf("-------\t\t------\t\t----\t\t------\t\t-------\n");
^
trigTable.c:28:2: error: expected identifier or ‘(’ before ‘for’
for(int degree = 0; degree <= 360; degree += degrees){
^
trigTable.c:28:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<=’ token
for(int degree = 0; degree <= 360; degree += degrees){
^
trigTable.c:28:44: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘+=’ token
for(int degree = 0; degree <= 360; degree += degrees){
^
trigTable.c:40:9: error: expected declaration specifiers or ‘...’ before string constant
printf("\nThank you for using trigTable. Bye.");
^
trigTable.c:41:2: error: expected identifier or ‘(’ before ‘return’
return 0;
^
trigTable.c:42:1: error: expected identifier or ‘(’ before ‘}’ token
}
^
Example of Output
Welcome to trigTable.
This program will print a table of trigonometric values
from 0 to 360 degrees in increments selected by the user.
Please the select the number of degrees for the increment: 30
--- TRIGONOMETRIC TABLE ---
Degrees Radians sine cosine tangent
------- ------- ------ ------ ---------
0 0.0000 0.0000 1.0000 0.00000
30 0.5236 0.5000 0.8660 0.57735
60 1.0472 0.8660 0.5000 1.73205
90 1.5708 1.0000 0.0000 infinity
120 2.0944 0.8660 -0.5000 -1.73205
150 2.6180 0.5000 -0.8660 -0.57735
180 3.1416 0.0000 -1.0000 -0.00000
210 3.6652 -0.5000 -0.8660 0.57735
240 4.1888 -0.8660 -0.5000 1.73205
270 4.7124 -1.0000 -0.0000 infinity
300 5.2360 -0.8660 0.5000 -1.73205
330 5.7596 -0.5000 0.8660 -0.57735
360 6.2832 -0.0000 1.0000 -0.00000
Thank you for using trigTable. Bye!
CODE THAT WONT COMPILE:
#include<stdio.h>
#include<math.h>
#define THRESHOLD 1e-10
int main(){
int increments;
printf("Welcome to trigTable.\n");
printf("This program will print a table of trigonometric values\n");
printf("from 0 to 360 degrees in increments selected by the user.\n\n");
printf("Please the select the number of degrees for the increment: ");
scanf("%d", &increment);}
printf("\t---\tTRIGONOMETRIC TABLE\t---\t\n\n");
printf("Degrees\t\tRadians\t\tSine\t\tCosine\t\tTangent\n");
printf("-------\t\t------\t\t----\t\t------\t\t-------\n");
for(int degree = 0; degree <= 360; degree += degrees){
double radians = degree * M_PI / 180;
double sine = sin(radian);
double cosine = cos(radian);
double tangent = tan(radian);
printf("%d\t\t%.4f\t\t%.4f\t\t%.4f\t\t", degree, radian, sine, cosine);
if (fabs(cosine) < THRESHOLD){
printf("infinity\n");
}else{
printf("%.5f\n", tangent);
}
}
printf("\nThank you for using trigTable. Bye.");
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images