![]() |
|
#1
|
|||
|
|||
I have no Idea how to programI'm new to programming in C, in fact I'm new to programming altogether. I have to write a program in C that:
computes the duration of a projectile's flight and it's height above the ground when it reaches the target. Problem constant G 32.17 (gravitational constant) Problem Inputs double theta (input angle) double distance (distance to target) double velocity (projectile velocity) Problem outputs double time (time of flight) double height (height at impact) relevant formulas time=distance/ velocity x cos(theta) height= velocity x sin(theta) x time - (g x time^2)/2 That is all of the info given in the book. I have no idea what to do with this info. I could really use some help with this. I know what all of the inputs and equations mean and I know how to do this on my own with paper, but I don't know how I would program this. I'd really appreciate any help on this subject. |
|||
|
#2
|
|||
|
|||
Re: I have no Idea how to programWithout knowing programming you won't be able to write that program. go to
http://www.cprogramming.com/ to learn C/C++ |
|
#3
|
|||
|
|||
Re: I have no Idea how to programThis is what I have so far, it is pretty bad. It won't even compile. If anyone could help out with the errors, or even if I am on the right track, I would appreciate it.
CPP / C++ / C Code:
The compiler is gcc, I don't know what that means, but it comes up with a lot of errors. The first of which is a parse error. What does that mean and how do I fix it? Again any help would be greatly appreciated. Last edited by LuciWiz : 29-Sep-2005 at 04:24.
Reason: Please insert your C code between [c] & [/c] tags
|
|
#4
|
|||
|
|||
Re: I have no Idea how to programDescribe me more and I may write this for you in C++(not in C). Tell me what are you trying to do more(in english)
|
|
#5
|
||||
|
||||
Re: I have no Idea how to programhi...
The basic structure of main function is: CPP / C++ / C Code:
Note that all the declaration should come first before you use any functions such as printf or scanf. This is the structure of the C program. so declare your variables at the start before entering in to the program.. The general form of a variable declaration and assignment is: type variable_name; where type is one of the C variable types (int, float, etc.) Name is any valid variable name. Example: CPP / C++ / C Code:
so you should not declare like this: Quote:
You must add semicolon ; every time when you end a statement. When you begin a curly brace { you should end with }. in your program you used an extra curly brace which is unnecessary and causes errors. gcc is the name of the gnu C++ compiler which comes with linux... and also note the general syntax of printf and scanf statements: CPP / C++ / C Code:
format: Format control. argument: Optional arguments. Return Value Returns the number of characters successfully printed or successfully converted and assigned respectively, or a negative value if an error occurs. Some examples of scanf and printf are: CPP / C++ / C Code:
and you need return statements only when you use functions(which you may learn later in the course)... so your return statements at the end is unnecessary and you can remove it.. And again, dont forget to insert semicolon at the end of each statement.. i hope this should help you to fix your errors... bye, Paramesh |
|
#6
|
||||
|
||||
Re: I have no Idea how to programi would strongly advice you to at least start learning basic input and output function first, instead of jumping STRAIGHT into solving programming questions =) step by step towards excellence.
Also realise that most compilers would change the color of keywords when you are coding, so you wont mix up keywords with variables. __________________
People should read the rules and regulation before posting! The Best is yet to be... |
|
#7
|
|||
|
|||
Re: I have no Idea how to programQuote:
__________________
Please read http://www.gidforums.com/t-5566.html. They were written to help you create a request that is readable and has enough information we can actually tell what you need help with. |
|
#8
|
||||
|
||||
Re: I have no Idea how to programQuote:
![]() __________________
The 3 Laws of the Procrastination Society: 1) Never do today that which can be put off until tomorrow 2) Tomorrow never comes |
|
#9
|
|||
|
|||
Re: I have no Idea how to programQuote:
Doen't matter. By writting this program I don't want to waste my t-t-time. |
|
#10
|
|||
|
|||
Re: I have no Idea how to programAnd yes by using float in mathematical code you will get more accurate reasult than using int. You can use double too.
|
Recent GIDBlog
Problems with the Navy (Enlisted) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 07:44 |
| Type casts ? | kai85 | C++ Forum | 12 | 23-Jun-2005 12:04 |
| [TUTORIAL] Calling an external program in C (Linux) | dsmith | C Programming Language | 4 | 22-Apr-2005 13:30 |
| fltk-2.0 cvs | Plumb | FLTK Forum | 20 | 13-Nov-2004 07:10 |
| Need help with a C program (Long) | McFury | C Programming Language | 3 | 29-Apr-2004 20:06 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The