C
03-Simple Calculation

Simple Calculation

Format

TypeSpecifierintput/output as
char%ccharacter
int,short%ddecimal integer
float%ffloating-point
double%lffloating-point
  • The default number of decimal places displayed by %f and %lf is 6. To display two decimal places, we write %.2f or %.2lf.

Simple input

The scanf(...) command takes in information from the user and keeps it in a special place in the computer's memory linked to a certain variable in the program.

scanf(format, address);
  • address: contains the address of the destination variable. use the prefix & to refer to the 'address of' of a variable.

Simple output

The printf(...) command shows the user the value of a certain variable or result of an operation.

printf(format, expression);