Professional Documents
Culture Documents
C Program
Carlo H. Coronel
ITA102 - Fundamentals of Programming,
Database Theory and Applications
Data Types
int (Integer)
can store a value in the range -32768 to
+32767. No fractional part.
Format:
int variable_name;
float (Float)
has about seven digits of precision and a
range of about 1.E-36 to 1.E+36.
Format:
float variable_name;
double (Double)
double, or double precision, number has about
13 digits of precision and a range of about 1.E-
303 to 1.E+303.
Format:
double variable_name;
char (Character)
- to store one character to a variable name, the
character should be enclosed in single quotes.
Single character.
Format:
char variable_name;
Example:
char first_char = ‘A’;
Layout of a Simple C Program
pre-processor directives
global declarations;
main( )
{
local variables to function main ;
statements associated with function main ;
}
Layout of a Simple C Program
#include <stdio.h>
main ()
{
int number, product;
int MULTIPLIER = 10;
printf (“Enter any number to be multiplied by 10\n”);
scanf (“%d”, &number);
product = number * MULTIPLIER;
printf (“%d * %d = %d”, number, MULTIPLIER, product);
}
Basic Input and Output codes
Format Specifiers
Format Specifiers