CS110_03b_conditional.c

CS110_03b_conditional.c - Conditionals Demo:

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Conditionals Demo: /*********************************** This program determines if a number is odd or even **********************************/ #include<stdio.h> main () { int number; printf("Please enter a number: "); scanf(" %d", &number); if (number % 2 == 0) printf("%d is even.\n", number); else printf("%d is odd.\n", number); } 18 A simple tax calculator /* This program calculates the tax for income between $0 and $14 */ #include<stdio.h> main () { int income; printf("Enter income in dollars: "); scanf("%d", &income); if (income < 0) printf("Invalid income\n"); else if (income < 5) printf("Tax = $0\n"); else if (income < 14) printf("Tax = $2\n"); else printf("You are rich!\n"); } 19 ...
View Full Document

Ask a homework question - tutors are online