Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
C++ : Input age of a person and print a message accordingly
SUBMITTED BY:
Guest
DATE:
Oct. 14, 2013, 3:52 p.m.
FORMAT:
C++
SIZE:
942 Bytes
Raw
Download
Tweet
HITS:
1097
Go to comments
Report
// Program Purpose: Input age of a person and print a message accordingly
#include
<stdio.h>
int
main
()
{
int
age
;
printf
(
"
\n
Please enter your age : "
);
scanf_s
(
"%d"
,
&
age
);
if
(
age
>=
16
)
{
printf
(
"
\n
You can get a driver's license."
);
if
(
age
>=
18
)
{
printf
(
"
\n
You can buy tobacco products, join the military, and legally vote."
);
if
(
age
>=
21
)
{
printf
(
"
\n
You can buy alcohol and legally gamble."
);
if
(
age
>=
25
)
{
printf
(
"
\n
You can get lower car insurance rates and become a US congressman."
);
if
(
age
>=
30
)
{
printf
(
"
\n
You can become a senator."
);
}
}
}
}
else
{
printf
(
"
\n
Stay at home, kid!"
);
}
}
getchar
();
getchar
();
return
0
;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus