Slide 2
Slide 2
int a;
int a;
variable names
correspond to memory
locations
memory
Data types
Name of variables
A variable name in C can be any valid identifier.
An identifier is a series of characters
consisting of letters (a-z, A- Z), digits (0-9) and
underscores (_) that does not begin with a digit.
Name of variables
int a1;
int 1al
int A1;
int abcdef;
int _ab;
int A1;
Name of variables
Assignment operator
Initializing variables
int a; //defining variable a
a=2; //assigning 2 to a
initializing variable a
Declaring multiple variables in
single statement
int a; int a, b;
int b; Data type same
int a; int a;
float b; Data type different float b;
Declare variables
before they are
used
Arithmetic Operation
int sum;
sum = a + b;
Arithmetic operator
Arithmetic Operation
Printing variables
printf(“Sum %d”, sum)
Conversion specifier
Printing multiple variables in single
statement
printf(“a = %d”, a);
printf(“b = %d”, b);
printf(“sum = %d”, sum);
AE:
C:
Algebraic and C Arithmetic Expressions
AE:
C:
Algebraic and C Arithmetic Expressions
AE:
C:
Algebraic and C Arithmetic Expressions
AE:
C:
Taking Input from User
printf("Enter integer a : "); Prompt
scanf("%d", &a);
Address operator
Taking Multiple Inputs in a single
statement
scanf("%d", &a);
scanf("%d", &b);