• Log in or sign up for an account here: https://www.sythe.org/login

C program help

fball56

Active Member
Joined
Nov 8, 2011
Sythe Gold
0
Messages
179
Location
Purdue
I am taking a programming class this semester and I am have trouble wit this homework. I think its called C so I hope this is the right place to post.

Here is the problem:
Problem: Given as integers (three in all) an angle in degrees, minutes, and seconds display the value converted
into radians.

Example Execution #1:
Enter number of degrees: 180
Enter number of minutes: 0
Enter number of seconds: 0
Data Entered: 180° 0' 0"
Radians Conversion: 3.1416

I have this program, but I can't compile it. What did I do wrong?

Code:
#include<stdio.h>

int main(void)
{
  // Local Declarations
  float d; // This will be the degrees of the angle
  float m; // This will be the minutes of the angle
  float s; // This will be the seconds of the angle
  float angle; // This will be the final angle in radians

  // Statements
  printf("\nEnter the number of degrees:");
  scanf("%f", &d);
  printf("\nEnter the number of minutes:");
  scanf("%f", &m);
  printf("\nEnter the number of seconds:");
  scanf("%f", &s);

 // Converting to radians
 angle =( 3.14159 / 180 ) * (d + (((m * 60) + 30) / 3600) )

 // The angle in radians
 printf("\nAngle in Radians: %5.5f\n\n", angle);

 return (0);
}
 
Hi, you have just 2 small errors. Usually a good compiler will tell you them. Here they are with explanations.

t.c: In function `main':
You can't have the type of a variable without its name in the function declaration so just remove the "void" and have no parameters.
Code:
int main()

t.c:23: error: syntax error before "printf"
Something wrong before "printf" on line 23 would mean looking at previous lines since that's the start of the line and sure enough the line before is missing the end semi-colon.
 
Thanks you so much!! That was it. It told me there were errors, but I didn't know what they meant.
 
Runescape Gamblingrunescape gambling
Back
Top