0% found this document useful (0 votes)
5 views148 pages

PSCP 1 2

The document outlines the syllabus and evaluation schema for the Programming and Data Structures course (CS1101), detailing lab programs, operators, control statements, arrays, functions, and structures in C++. It includes specific assignments and examples for practical understanding of concepts like arithmetic, relational, and logical operators, as well as function overloading and recursion. Additionally, it emphasizes the importance of operator precedence and provides guidance on using conditional statements and arrays in programming.

Uploaded by

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

PSCP 1 2

The document outlines the syllabus and evaluation schema for the Programming and Data Structures course (CS1101), detailing lab programs, operators, control statements, arrays, functions, and structures in C++. It includes specific assignments and examples for practical understanding of concepts like arithmetic, relational, and logical operators, as well as function overloading and recursion. Additionally, it emphasizes the importance of operator precedence and provides guidance on using conditional statements and arrays in programming.

Uploaded by

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

Programming and Data

Structures
Subject Code: CS1101 LTP: 3-0-0 (3)
Syllabus:
Evaluation Schema
• Attendance: 10 Marks
• Minor-1 : 10 Marks
• MID : 30 Marks
• Minor-2 : 10 Marks
• End Exam: 40
decltype
C++11 also introduces a way to determine the type of a variable or expression.
decltype (expr) is the declared type of variable or expression expr and can be
used in declarations:
Lab Programs
 WAP to calculate Total Salary of employee provided Name as First name, Middle name and Last name, Basic, HRA (18% of
basic), DA (50% of basic)
 WAP to calculate CGPA of student
Notes:
Take name of employee as First name, Middle name and last name and Append Dr. salutation to name
and display as Dr. First name Middle Name and Last Name
Ex: Mr. Shiva Rama Krishna
Output: All the details along with Total Salary/CGPA
 Check the bool data type functionality by assigning zero, positive and negative values. Make your observations
 Take two bool variables perform addition, subtraction, multiplication using them. Make your observations
 Take fixed width integers and try to store the numbers beyond the range ? Draw your observations?
Operators
Operators in C++ can be classified into 6 types:
• Arithmetic Operators
• Assignment Operators
• Relational Operators
• Logical Operators
• Bitwise Operators
• Other Operators
Arithmetic Operators
• Arithmetic operators are used to perform arithmetic operations on
variables and data.
Arithmetic Operators Program

Click her to RUN the code


Points to be noted
Division Operator (/ ):
As we can see from the above example, if an integer is divided by another integer, we will get the quotient.
However, if either divisor or dividend is a floating-point number, we will get the result in decimals.

Example

Modulo Operator (%)

The modulo operator % computes the remainder. When a = 9 is divided by b = 4, the remainder is 1.
Increment and Decrement
Operators
Example code on Increment and Decrement Operators

Click here to RUN Code


Pointes to be noted

In the above program, we have used the ++ and -- operators as prefixes (++a and --b). However, we can also use these
operators as postfix (a++ and b--).
C++ Assignment
Operators
C++ Assignment Operators
Example on Assignment Operators

Click here to RUN this Code


C++ Relational
Operators
C++ Relational Operators
Click her to RUN this code
C++ Logical
Operators
C++ Logical Operators
Example 5: Logical Operators

Click here to RUN this code


C++ Bitwise
Operators
C++ Bitwise Operators
Important Points

The left-shift and right-shift operators should not be used for negative
numbers.
The result of is undefined behavior if any of the operands is a negative
number. For example results of both 1 >> -1 and 1 << -1 is undefined.
Other C++
Operators
Other C++ Operators
Conditional
Statements
• to create decision making

• if,
• if...else and
• Nested if...else
In computer programming, we use the if...else statement to run one block of code under certain conditions and
another block of code under different conditions.
How if Statement Works
WAP to print positive number entered by the user

SimpleIf.cpp

Click her to Run this Code


C++ if...else
How if...else Statement Works
WAP Program to check whether an integer is positive or negative

Click her to run this code


C++ if...else...else if statement
How if...else if...else Statement Works
Program to check whether an integer is positive, negative or zero

Online C++ Compiler (programiz.com)


C++ Nested if...else
C++ program to find if an integer is positive, negative or zero
Switch case

case value can only be of type int or char.


C++ Operator Precedence
and Associativity
C++ Operator Precedence and
Associativity
C++ Operators Precedence Table

Precedence Level 1 signifies operators of highest priority, while Precedence Level 17 signifies operators of the lowest priority.
C++ Operators Associativity

Operator associativity is the direction from which an expression is evaluated.


For example,

Also, multiple operators can have the same level of precedence (as we can see from the above
table). When multiple operators of the same precedence level are used in an expression, they are
evaluated according to their associativity.
Arrays
C++
Multidimensional
Arrays
Multidimensional Array
Initialization
Initialization of three-dimensional array
C++ Program to display all elements // of an initialised two dimensional array
Taking Input for Two Dimensional Array
Note
Three Dimensional Array
Assignment's
• WAP to perform matrix addition.
• WAP to perform matrix multiplication.

Hints:
Character Arrays
C++ Functions
C++ User-defined Function
Calling a Function
Function Parameters
C++ Library Functions
Assignements
• WAP for factorial using function
• WAP to find any table using function
• WAP to print sum of the digits of given number using function.
• WAP to
C++ Programming Default Arguments
(Parameters)
Function overloading
C++ Recursion
Working of Factorial Program
Assignements
Passing Array to a Function
in C++ Programming
Strings
Passing String to a Function

Strings are passed to a function in a similar way


arrays are passed to a function.
C++ Structures
Passing structure to
function in C++
Passing structure to
function in C++
Pointers to Structure
Enumeration

You might also like