The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
please help
Discuss please help in the C Programming forum on Dev Shed. please help C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 1st, 2003, 04:40 PM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
please help
//There are approximately 3.156X10^7 seconds in a year. Write a program that request your age in years and then displays the equivalent number of seconds//
// Example output for a person 1 year old: (notice three values are being output in the following line, not 2 as shown in the textbook)
// Your age in years: 1, age in seconds: 31560000.000 or 3.156e+007.
// your output must be formatted exactly like the example above, or like the following:
// Your age in years: 1, age in seconds: 31560000.000 or 3.156e+07. //
#include <stdio.h>
void GetAge(void)
void PrintAge(void)
int main(void)
{
void GetAge();
void PrintAge()
return 0;
}
void GetAge()
{
int age;
printf("what is your age ");
scanf("%d", &age);
printf("so you are %d years old",age);
return 0;
}
void PrintAge (void)
{
printf("display you age in %d,%f,%e ");
}
please help me with syntax error . or the functions
|

February 1st, 2003, 10:41 PM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
|
Three things:
1) There are three lines missing a semi-colon from the end of it. Both of the function declarations at the beginning and the second function call in the main function block.
2) Always show the error you are receiving so that it is easier to determine the problem.
3) It is frowned upon to get help for homework. You should approach your teacher & peers first.
|

February 8th, 2003, 03:47 PM
|
 |
not a fan of fascism (n00b)
|
|
Join Date: Feb 2003
Location: ct
|
|
|
in addition to what he said,
void GetAge()
{
int age;
printf("what is your age ");
scanf("%d", &age);
printf("so you are %d years old",age);
return 0;
}
should not return a value as it is void but u return 0, i would also always initialize my variables to 0 or null.
|

February 8th, 2003, 05:19 PM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 8
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
You really should ask your teacher and/or your fellow students. I have a copy of your program on my computer and here is how to fix everything. This is everything, and it will work if you do all of these things:
1. Semicolons at the end of lines 3, 4, and 9
2. In the GetAge() menthod, change it from 'void GetAge()' to 'int GetAge()'
3. In the 'main()' function, get rid of the two 'voids' in front of where you call both of the functions.
4. In the GetAge prototype, change the 'void' in front to be 'int'
It runs. You get the red screen of death, but I assume that this isn't your entire program.
|

February 8th, 2003, 05:22 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
|

February 9th, 2003, 11:48 AM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
Your right, that should have been #1 on the list. 
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|