Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

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;
}
                                       

 

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education