[go: up one dir, main page]

0% found this document useful (0 votes)
20 views28 pages

PCBasedControl Section3

Uploaded by

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

PCBasedControl Section3

Uploaded by

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

Introduction to C++

Programming Language
INTRODUCTION OF PC BASED CONTROL

Eng. Esraa Adel


C++ If Condition
We use these conditions to perform different actions based on some
conditions.
C++ has the following conditional statements:
if: is used to make a block of code executed if a specified condition is
true.
else: is used to specify a block of code to be executed, if the same
condition is false.
else if: is used to specify a new condition to be tested, if the first
condition is false.
C++ If Condition
If Statement Example:
C++ If Condition
If else Statement Example:
else If Condition
If else Statement Example:
C++ Comparison Operators
C++ Logical Operators
C++ Switch Statements
C++ Switch Statements
A simple calculator is a device used to perform basic arithmetic
operations such as addition, subtraction, multiplication, and
division. It makes arithmetic calculations easier and faster. In
this article, we will learn how to code a simple calculator using
C++.
Examples
Input: Enter an operator (+, -, *, /): *
Enter two numbers: 10 5
Output: Result: 50
Explanation: Chosen operation is addition, so 10 * 5 = 50
Using Switch Case
Using Switch Case
Using Switch Case
Using if-else statements
Using if-else statements
Write a C++ program to convert temperature in Celsius to Fahrenheit.

Sample Output:
Convert temperature in Celsius to Fahrenheit :
---------------------------------------------------
Input the temperature in Celsius : 35
The temperature in Celsius : 35
The temperature in Fahrenheit : 95

Note:
Write a Program to Check Whether a Number Is Prime or Not.
Assignment
1. Write C++ Program to convert a positive number into a negative
number and negative number into a positive number.

Example Output

Select 1, for Negative to positive


Select 2, for positive to negative

1
Enter a Negative number
-6
the positive form of the number is
6
2. Write a C++ program to Show grades with marks percentage
using the switch statements. .

Percentage >= 90% : Grade A


Percentage >= 80% : Grade B
Percentage >= 70% : Grade C
Percentage >= 60% : Grade D
Percentage >= 40% : Grade E
Percentage < 40% : Grade F
Example Output #1

Enter total marks obtained:

85

Grade: A

Example Output #2

Enter total marks obtained:

95

Grade: A+

You might also like