0% found this document useful (0 votes)
485 views

Programming Fundamentals - Lecture 03

This lecture introduces programming fundamentals including variables, data types, operators, and precedence. Key points covered are: - A variable has a name, type, size, and value and is used to store data in memory locations. - Common data types include int, float, char. - Assignment (=) and arithmetic (+, -, *, /, %) operators are used to assign values and perform math operations. - Operator precedence defines the order that operations are performed, with parentheses having highest precedence.

Uploaded by

api-284716142
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
485 views

Programming Fundamentals - Lecture 03

This lecture introduces programming fundamentals including variables, data types, operators, and precedence. Key points covered are: - A variable has a name, type, size, and value and is used to store data in memory locations. - Common data types include int, float, char. - Assignment (=) and arithmetic (+, -, *, /, %) operators are used to assign values and perform math operations. - Operator precedence defines the order that operations are performed, with parentheses having highest precedence.

Uploaded by

api-284716142
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

Programming Fundamentals

Lecture No. 3

#include <iostream.h>
main ( )
{
cout << Welcome to ITC Tandojam;
}

Variable
Variable

Variable

Pic of the memory

25

10323

name
of the
variabl
e

Variable
Variable starts with
1. Character
2. Underscore _ (Not Recommended)

Variable

Small post box

Variable
Variable is the name of a location
in
the memory
e.g.

x= 2;

Variable
In a program a variable
has:
1. Name
2. Type
3. Size
4. Value

Assignment Operator

x=2

Assignment Operator

L.H.S = R.H.S.

X+ 3 = y + 4 Wrong
Z = x +4
x +4 = Z

Wrong

X = 10 ;
X = 30 ;

10

30

X = X + 1;
X

10

+ 1

= 11
X

Data type
int i ; ->
Declaration line

#include <iostream.h>
main ( )
{
int x ;
int y ;
int z ;
x = 10 ;
y = 20 ;
z=x+y;
cout << " x = " ;
cout << x ;
cout << " y = " ;
cout << y ;
cout << " z =x + y = " ;
cout << z ;
}

int x, y, z ;
int x; int y; int z ;

Data Types
1. int
2. short
3. long
4. float
5. double
6. char

Arithmetic operators
Plus

Minus

Multiply

Divide

Modulus

Arithmetic operators
i+j
x*y
a/b
a%b

% = Remainder
5%2=1
2%2=0

4/2=2
5/2=?

Precedence
Highest:
()
Next: * , / , %
Lowest:
+,-

You might also like