0% found this document useful (0 votes)
6 views9 pages

PF Assignment

The document is an assignment on programming fundamentals submitted by Muhammad Ashir Munir. It covers key concepts in C++ such as data types, if statements, if-else statements, if-else ladder, conditional operators, and switch statements, along with examples and code snippets. The assignment is intended for a computer science course at KICSIT, Kahuta.

Uploaded by

pindi90ch
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)
6 views9 pages

PF Assignment

The document is an assignment on programming fundamentals submitted by Muhammad Ashir Munir. It covers key concepts in C++ such as data types, if statements, if-else statements, if-else ladder, conditional operators, and switch statements, along with examples and code snippets. The assignment is intended for a computer science course at KICSIT, Kahuta.

Uploaded by

pindi90ch
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

Programming Fudnamentals

Assignment no 01
BSCS I-D

Submitted to:
Ma’am Maheen

Submitted by:
Muhammad Ashir Munir 188

Department of Computer Science,


KICSIT, Kahuta.

[27/10/2025]
Q:1 What is the use of Data Types in C++?

Ans. Data types are used to stores diffrent types of data in C++. There are many Data
types in C++ for example: int , float , char , bolean ,double.

Q:2 What is If statement?


Ans. An if statement is a decision making statement in C++.It allows the program to
execute a block of code only when a specific condition is [Link] the condition is false,
the code inside the if block is skipped.

Q:3 What is If else statement?

Ans. An if else statement is a decision making statement in C++.It allows the program to
execute a block of code only when a specific condition is [Link] the condition is false,
the code inside the if block is skipped and statements inside else is running.

Q:4 What is if else ladder statement?


Ans. An if else ladder is used when we have multiple conditions to check one after another.
The program will:

 Check each condition from top to bottom


 Execute the first true condition’s block
 Skip all the rest

If none of the conditions are true, the block runs.

Examples of If else ladder statements with codes:


Program 1:
Calculator using If else ladder:

Program 2:
Grades using If else ladder:
Program 3:
Temperature Check using If else ladder:
Q.5 What is Conditional operator in C++?
Ans. The conditional operator also known as ternary operator is a short form of if else statement.
It is used to make a quick decision in a single line.

It uses three parts so it’s called ternary:

 If the condition is true, the first expression runs.


 If the condition is false, the second expression runs.

Example with Codes:


Program 1:
Calculator using Condiotional operator.
Program 2:Grades using Condition

al operator.
Program 3:
Even odd using condiotional operator.

Q.6 What is Switch statement in C++?


Ans. A Switch statement is a multi-way decision-making [Link] allows your
program to choose one option from many possible cases based on the value of a single
variable or expression.

Q. How to use switch statement

1. The expression inside Switch must be integer, char, or enum (not float/double).
2. Each case must have a constant value.
3. The break keyword stops the switch after a match is found.
4. The default case runs if no other case matches (optional but recommended).

Examples of Switch satements using codes in C++:


Program 1 :
Calculator using Switch statement.

Program 2:Grades using Switch satements:


Program 3:

Vowels or consonats using switch statement.

You might also like