Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void main()
- {
- int age, curryear, birthyear;
- printf ("Enter current year: ");
- scanf ("%d", &curryear);
- printf ("Enter birth year: ");
- scanf ("%d", &birthyear);
- //if (curryear - birthyear <=20) /*<- if statement was in the wrong place.*/
- {
- age = curryear - birthyear; /*NOTE TO SELF: Removing this line yields a very
- interesting result.*/
- if (curryear - birthyear <=20) /*NOTE TO SELF: Condition following if statement
- must always go in parentheses.*/
- // if (age <=20)/*Easier (more appropriate)if statement (*Lvalue over Rvalue)*/
- printf ("\nAge is: %d\n\n", age);
- }
- system ("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment