0% found this document useful (0 votes)
18 views5 pages

Introduction To Dev C For VIII 8th Class 2023 (Final 2nd Semester)

The document discusses C++ programming concepts like operators, loops, and flowcharts for programs. It defines increment and decrement operators, arithmetic assignment operators, and the different types of loops like for, while, and do-while loops. It also includes flowcharts and code for programs to calculate the area of a rectangle, convert between centimeters and meters, convert between Fahrenheit and Celsius temperatures, and print the multiples of a number up to 10.

Uploaded by

mahmood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views5 pages

Introduction To Dev C For VIII 8th Class 2023 (Final 2nd Semester)

The document discusses C++ programming concepts like operators, loops, and flowcharts for programs. It defines increment and decrement operators, arithmetic assignment operators, and the different types of loops like for, while, and do-while loops. It also includes flowcharts and code for programs to calculate the area of a rectangle, convert between centimeters and meters, convert between Fahrenheit and Celsius temperatures, and print the multiples of a number up to 10.

Uploaded by

mahmood
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Final 2nd Semester for Class VIII

Dev C ++ Language
Q1- Define increment (+ +) and decrement Operator ( ̶ ̶ )
Increment Operator:
The increment operator can be used with any type of variable.
It is used to add 1 to the value of a variable.
It is represented by + + (double plus sign).
It is used in two ways;
They can be uses into ways.
1. (+ + variable name; i.e. + + a;) first increase by one than further process. This type is called
“Prefix” operator.
2. (variable name ++; i.e. a + +;) first process than increase by one. This type is called “Postfix”
operator.
Decrement Operator:
The increment operator can be used with any type of variable.
It is used to subtract 1 from the value of a variable.
It is represented by ̶̶ ̶̶ (double minus sign).
It is used in two ways;
They can be uses into ways.
1. ( ̶̶ ̶̶ variable name ; i.e . ̶̶ ̶̶ a;) first decrease by one than further process. This type is called “Prefix”
operator.
2. (variable name ̶̶ ̶̶ ; i.e. a ̶̶ ̶̶ ;) first process than decrease by one. This type is called “Postfix”
operator.

Q2- Define Arithmetic Assignment Operations.


Ans. In arithmetic assignment operators, the arithmetic operator is combined with the assignment operator.
It (Add, Subtract, Multiply & Divide) the right operant to the left operand.
Then assigns the result to the left operand.
Operators Example
+= (Addition-assignment) A+=2;  means a=a+2;
– = (Subtraction-assignment) A–=3;  means a=a–3;
*= (Multiplication-
A+=5;  means a=a*5;
assignment)
/= (Division-assignment) A+=2;  means a=a/2;
Q3- Define loop (iteration)
Ans. Loop / Iteration:
Normally statements are executed sequentially, one after the other. Loops are allowed to execute a
statement or a group of statements several numbers of times. A group or block is made by enclosing
statements in braces. There are three types of loops in C++.
1. “for” Loop 2.”while” Loop 3. “do- while” Loop

Q4- Define “for” Loop with syntax and example.


Ans. “for” Loop:
This loop executes a sequence of statements multiple times.
It is usually used in situations where we know that how many times loop block will execute.
It is a pre-test loop as condition is tested at the start of loop.
Loop expression has three parts separated by semicolon.
First part is initialization the variable;
Second part is test expression.
Third part is increment or decrement in loop variable.
Syntax:
for (initialization; condition testing; increment/decrement)
{
statement(s);
}
Example: WAP to print first ten natural numbers
#include <iostream>
using namespace std;
int main ( )
{
int a;
for (a = 1; a <= 10; a + +)
{
cout << a << endl ;
}
return 0;
}
Flowchart for Practical#01
“Program to find the area of rectangle.”

Start

Declare Variable
Float length, width & area

Read
length, width

area = length * width

Write
area

Stop
Source Code:-

#include <iostream>
using namespace std;
int main ()
{
float length, width, area;
cout<<"\n \t \t Area of Rectangle";
cout<<"\n \t \t *****************";
cout<<"\n \t Enter Length \t";
cin>>length;
cout<<"\n \t Enter Width \t";
cin>>width;
area=length*width;
cout<<"\n \t Area of Rectangle is............"<<area;
return 0;
}
Flowchart for Practical#02
“Program to input length in centimeter and convert it into meter.”

Start

Declare Variable
Float centimeter

Declare Variable
Float meter

Read
centimeter

meter=centimeter/100

Write
meter

Stop

Source Code:-

#include<iostream>
using namespace std;
int main ()
{
float centimeter, meter;
cout<<"\n \t \t CONVERT CENTIMETER INTO METER";
cout<<"\n \t \t ************************************* ";
cout<<"\n \t Enter Length into Centimeter \t";
cin>>centimeter;
meter=centimeter/100;
cout<<"\n \t Converted Length into Meter ............"<<meter;
return 0;
}
Flowchart for Practical#03
“Program to convert temperature from Fahrenheit into Celsius.”

Start

Declare Variable
Float feh & cel

Read
fah

cel = (fah – 32) * 5/9

Write
cel

Stop

Source Code:-

#include <iostream>
using namespace std;
int main ()
{
float fah, cel;
cout<<"\n \n \t \t Convert Fahrenheit into Celsius";
cout<<"\n \t \t ***************************** ";
cout<<"\n \n \t Enter Temperature from Fahrenheit \t";
cin>>fah;
cel=(fah-32)*5/9;
cout<<"\n\n \t Converted Temperature into Celsius ............"<<cel<<char(248)<<"C";
return 0;
}
Flowchart for Practical#04
“Program to takes a number and prints its multiples up to 10.”

Start

Declare Variable
Int t, a, c

Read
t

a=1

a=a+1

True
a<=10? c=t*a

False

Write
Stop t "x" a "=" c

Source Code

#include <iostream>
using namespace std;
int main ()
{
int t,a,c;
cout<<"\n \t \t TABLE OF ANY NUMBER";
cout<<"\n \t \t *************************";
cout<<"\n \t Enter Table Number \t";
cin>>t;
for (a=1;a<=10;a=a+1)
{
c=t*a;
cout<<"\n \t \t \t"<<t<<"x"<<a<<"="<<c;
}
return 0;
}

You might also like