CS110_02a_IOdemo.c - Input/output 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: Input/output Demo: /*********************************** Read an integer from the keyboard, then report it as odd or even. ************************************/ #include<stdio.h> Int main(void) { 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); } return 0; } 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

This note was uploaded on 10/05/2011 for the course COMPUTER S 110-1 taught by Professor Tumblin during the Spring '11 term at Northwestern.

Ask a homework question - tutors are online