Review Lecture 2-11-2024 (Autosaved)

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 17

Review lecture

Corse instructor
Mr. Shahid Mehmood
Lecture no 1
 Basic of computer
 Software and hardware
 Software types
 Programming languages types
 Procedural VS Object Oriented Languages
 Compiler VS Interpreter
 Problem solving principal
 Types of error
 Control Structure + Event Driven
Programming
Lecture-2
 Program and Computer Program
 • Language and Computer Language
 • Evolution of Programming Languages
 • Introduction to c++
 • Language Processor or Translators
 importance of header and main function.
 importance of body and statement’s
 Structure of Programming by using
DevC++
Review
 Set of rules to write an instructions in high
level
language is called
a) Semantic
b) Syntax
 The computer can understand only a

___________
language.
 C ++ programs are converted into machine

language with the help of


a) Editor b) Compiler c) Operating System
Review
 __________ converts the programs written in
assembly language into machine instructions.
a) Machine compiler b) Interpreter
c) Assembler d) Converter
Characteristics of C++ language are________
a) Efficient and fast

b) Highly portable

c) Highly flexible

d) All above
Lecture-3
 Familiar with Dev C++ IDE and program
structure
 Preprocess Directive
 Use of # Include
 # Define Preprocess Directive
 Main function and types
 Namespace
 Familiar with iostream
 Concept of delimiters
 Predefined C++ Macros
Review
 The operator << is called
a) Insertion operator b) extraction operator
c) Put to operator d) None
 The directives for the preprocessors begin with

a) Ampersand symbol (&) b) Two Slashes (//)


c) Number Sign (#) d) Less than symbol (
 Every statement in C++ program should end

with
a) A full stop (.) b) A Comma (,)
c) A Semicolon (;) d) A colon (:)
Review
 What value will return to the operating
system
upon the successful completion on a
program
a) -1 b) 1 c) 0 d) None
 Void main() function reture 0

a) True
b) False
Review
 Software can be further subdivided into _____&______
 C++ is a procedural or object oriented language_____
 OOP languages based on structure or modeling______
 C++ is compiler or interpreter based_______________
 Problem solving principal composed of__________steps
 How many step in developing program________
 How many types of documentation__________
 Types of error are_____________
Practice
 Add the code on the doted lines in the following program to generate the output
given after the source code.
void main ( )
{
int x=100;
float y=6.0;
……………………… // add your code here
…………………….
}
Required Output
 The x value is : 100
 The y value is : 6.0
 The sum of x & y is : ????
 The product of x&y is : ????

Practice
 Write a program that prints the numbers
1 to 4 on the same line with each pair of
adjacent numbers separated by one
space.
 Write the program using the following methods:
 a) Using one output statement with one stream insertion operator.
 b) Using one output statement with four stream insertion operators.

c) Using four output statements .
Todays practice
 Write a program that inputs three integers
from the keyboard and prints the sum,
average, product, smallest and largest of
 these numbers. The screen dialogue should
appear as follows:
Input three different integers: 13 27 14
Sum is 54
Average is 18
Product is 4914
Smallest is 13
Largest is 27
2nd program solution
#include <iostream>
using std::cout;
using std::endl;
int main ()
{
// Part A
cout << "1 2 3 4\n";
// Part B
cout << "1 " << "2 " << "3 " << "4\n";
// Part C
cout << "1 ";
cout << "2 ";
cout << "3 ";
cout << "4" << endl;
return 0;
}
3rd
program solution
#include <iostream>
if ( num2 < smallest )
using std::cout;
using std::endl; smallest = num2;
using std::cin;
if ( num3 < smallest )
int main()
{ smallest = num3;
int num1, num2, num3, smallest, largest; // declaration
cout << "Sum is " << num1 +
cout << "Input three different integers: "; // prompt
num2 + num3
cin >> num1 >> num2 >> num3; // input
largest = num1; // assume first number is largest << "\nAverage is " << (num1
if ( num2 > largest ) // is num2 larger? + num2 + num3) /
largest = num2;
<< "\nProduct is " << num1 *
if ( num3 > largest ) // is num3 larger?
largest = num3;
num2 * num3
smallest = num1; // assume first number is smallest << "\nSmallest is " << smallest
<< "\nLargest is " << largest
<< endl;
return 0;
}
Today Lab assignment

 Write a program that reads in the radius of a circle and prints the
circle’s diameter, circumference and area. Use the constant value
3.14159 for .
Important note: Do these calculations in output statements.
Hint:- Diameter = radius *2, Circumfrence= 2*pi*r, Area= pi*r*r
Program no 2
 Write a program that prints a box, an oval, an arrow and a diamond as
follows:
Lab solution
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
int main()
{
int radius; // declaration
cout << "Enter the circle radius: "; // prompt
cin >> radius; // input
cout << "Diameter is " << radius * 2.0
<< "\nCircumference is " << 2 * 3.14159 * radius
<< "\nArea is " << 3.14159 * radius * radius << endl;

return 0;
}
Lab solution
#include <iostream>
using std::cout;
using std::endl;
main()
{
cout << "********* *** * *\n"
<< "* * * * *** * *\n"
<< "* * * * ***** * *\n"
<< "* * * * * * *\n"
<< "* * * * * * *\n"
<< "* * * * * * *\n"
<< "* * * * * * *\n"
<< "* * * * * * *\n"
<< "********* *** * *" << endl;
return 0;
}

You might also like