Revision of Programming Concepts for OOP
Revision of Programming Concepts for OOP
lrikjdj
Revision of Programming Concepts
Flowchart
• Draw a flowchart to take average of four subject marks and display
grade on the basis of it
Solution Start
M= E,M,P,C
Avg = (E+M+P+C) / 4
Yes
Print Pass if Avg >=50
No
• Syntax:
if(cond){ }
elseif(cond){ }
else{ }
Solution: if(angle == 90)
#include<iostream> {
using namespace std; cout<<"Square"<<endl;
}
int main() }
{ else
int length, breadth, angle; {
cin>>length; cout<<"Not square"<<endl;
cin>>breadth; }
if(length == breadth) }
{
cin>>angle;
Loop
• Differentiate between different types of loop
• Write a C++ program using for loop to print even numbers
between 1 to 10.
• Syntax:
for(initialization; condition; increment)
{ }
Solution
while Loop
• Write a C++ program to find factorial of a positive integer
entered by user.
• Syntax
Initialization
while(cond)
{
increment
}
Solution
do while Loop
Dry Run both the code
Nested Loop
• Write a C++ program using nested for loop to print the
following
Solution
Nested Loop Flowchart
• Draw the flowchart of previous example code
Solution