Professional Documents
Culture Documents
Programming Fundamentals: by Imran Kazmi
Programming Fundamentals: by Imran Kazmi
Programming Fundamentals: by Imran Kazmi
Lecture 6
by
Imran Kazmi
Assignment given in the previous lecture
1) Write a program that input number of week’s day and display the name of the
day. For example if user enters 1, it display Friday and so on.(use switch statement)
2) write a program that input two numbers and an operator( +,-,*,/), in case the
operator is +, addition of two numbers is calculated, for * multiplication is
calculated and so on( (i) use switch statement, (ii)use if-else) .
3) Write a program to check whether a triangle is valid or not, while three angles of
the triangle is input through the keyboard. Triangle is valid if the sum of triangle is
equal to 180 degree.
4) Write a program to calculate the roots of the quadratic equation while value of a
, b and c is input through the keyboard. All cases should be discussed(b2-4ac>0,
b2-4ac<0,b2-4ac=0).
Loop Control Instructions
int sum ;
sum = 1+2+3+4+5+……..+10 ;
cout << sum ;
Loop Control Instructions
start
Initialize
False
test
True
stop
Body of loop
Increment/decrement
Loop
• Basic three methods through we can repeat a
part of a program