IO - scanf Reads in information from the keyboard Examples...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
scanf Reads in information from the keyboard Examples scanf(“%d”, &number); scanf(“%d%d”, &value1, &value2); WARNINGS! Don’t forget the & (address of) in front of each variable! Use the correct percent code for the type of the variable you are using!
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
/* Arup Guha My Second C Program, edited 9/2/03 Computes the number of feet user ran. */ #include <stdio.h> #define YARDS_IN_MILE 1760 #define FEET_IN_YARD 3 int main(void) { int feet_in_mile, num_miles; feet_in_mile = YARDS_IN_MILE*FEET_IN_YARD; printf("How many miles did you run?\n"); scanf("%d", &num_miles); printf("You ran %d feet.\n", feet_in_mile*num_miles); // system(“PAUSE”); Necessary to see screen in DevC++ return 0; }
Background image of page 2
Programming Style Include ample white space Indent code in between matching {} Always write a header comment Comment each major block of code Use meaningful variable names Define constants when appropriate Be consistent with your style
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/25/2010 for the course COMPUTER S COP3223 taught by Professor Lobo during the Spring '10 term at University of Central Florida.

Page1 / 11

IO - scanf Reads in information from the keyboard Examples...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online