0% found this document useful (0 votes)
0 views

CS Section3

The document provides an introduction to C++ programming, focusing on conditional statements such as if, else, and else if. It includes examples of using these statements in coding a simple calculator and converting temperatures from Celsius to Fahrenheit. Additionally, it covers comparison and logical operators, as well as switch statements in C++.

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)
0 views

CS Section3

The document provides an introduction to C++ programming, focusing on conditional statements such as if, else, and else if. It includes examples of using these statements in coding a simple calculator and converting temperatures from Celsius to Fahrenheit. Additionally, it covers comparison and logical operators, as well as switch statements in C++.

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/ 22

Introduction to C++

Programming Language
COMPUTER SCIENCE

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:

You might also like