Sythe.Org Forums     Register     FAQ     Members List     Calendar     Mark Forums Read    
 
Sythe.Org Forums  
   Runescape Gold

Sythe.org — A Virtual Goods Trading Hub

Make real cash! buying and selling in-game items.

We have a no-scam policy.

You can make thousands playing your favourite games here at Sythe.org.

Just sign up an account and follow the rules!


Take me to

Runescape Markets

Other Game Markets

Support Center

Register an Account

Close
C program help
Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 01-21-2012, 08:38 PM
fball56's Avatar
Active Member
 
Join Date: Nov 2011
Location: Purdue
Posts: 179
Default C program help

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

Last edited by fball56 : 01-21-2012 at 08:47 PM.
Reply With Quote
  #2  
Old 01-21-2012, 11:34 PM
Guru
 
Join Date: Jan 2007
Location: /home/Canada
Posts: 1,768
Default Re: C program help

Hi, you have just 2 small errors. Usually a good compiler will tell you them. Here they are with explanations.

Quote:
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()
Quote:
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.
Reply With Quote
  #3  
Old 01-21-2012, 11:59 PM
fball56's Avatar
Active Member
 
Join Date: Nov 2011
Location: Purdue
Posts: 179
Default Re: C program help

Thanks you so much!! That was it. It told me there were errors, but I didn't know what they meant.
Reply With Quote
Reply



Cheap RS Gold Store  Runescape Gold

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

All times are GMT +1. The time now is 11:38 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.1