Voting Program

R

RobBob

Can anyone help me with this.I have to write a program that prompts a user
for his or her age, then computes whether they are old enough to vote - age
18. If they are too young, your program should inform them that they can
vote in XX years. If they are old enough, you should inform them that they
have been eligible to vote for YY years.
So far this is what I've come up with but I keep getting errors:
#include <stdio.h>
#include <stdlib.h>
int age;
printf("please enter your age:");
get(age);
if(age<18)
total=18-age
{
printf("I'm sorry you are too young to vote. You will be eligible
to vote in '%;' years");
}
else
total=age-18
{
printf" You can vote! You have been eligible to vote for, '%;'
years");
}
return()
 
O

osmium

RobBob said:
Can anyone help me with this.I have to write a program that prompts a user
for his or her age, then computes whether they are old enough to vote -
age 18. If they are too young, your program should inform them that they
can vote in XX years. If they are old enough, you should inform them that
they have been eligible to vote for YY years.
So far this is what I've come up with but I keep getting errors:
#include <stdio.h>
#include <stdlib.h>
int age;
printf("please enter your age:");
get(age);
if(age<18)
total=18-age
{
printf("I'm sorry you are too young to vote. You will be eligible
to vote in '%;' years");
}
else
total=age-18
{
printf" You can vote! You have been eligible to vote for, '%;'
years");
}
return()

If you get compile errors take stuff out until the error goes away. Then
see what is wrong with what you most recently took out.

Hint:
1 You need a "main" function in each program.
2 You can only call functions that you have provided, either directly or by
indirection via. an <include> file. Where does get() fit into this scheme
of things?
3 Review your source material WRT the mysterious % character. You seem to
attribute some kind of magic or special meaning to it..
4. There are other problems as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top