0% found this document useful (0 votes)
17 views36 pages

AIReport (17) - 11

The document is a course report submitted by Yazdan Abbas on programming principles, covering topics such as flowcharts, data types, operators, control structures, functions, and arrays. It includes a plagiarism declaration and acknowledgments for guidance received during the assignment. The report is structured with an abstract, detailed contents, and references, totaling 34 pages.

Uploaded by

yazdanrizvi211
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)
17 views36 pages

AIReport (17) - 11

The document is a course report submitted by Yazdan Abbas on programming principles, covering topics such as flowcharts, data types, operators, control structures, functions, and arrays. It includes a plagiarism declaration and acknowledgments for guidance received during the assignment. The report is structured with an abstract, detailed contents, and references, totaling 34 pages.

Uploaded by

yazdanrizvi211
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/ 36

Page 1 of 36 - Cover Page Submission ID trn:oid:::17268:95906171

Submission
My Files

My Files

University

Document Details

Submission ID

trn:oid:::17268:95906171 34 Pages

Submission Date 3,342 Words

May 14, 2025, 11:36 PM GMT+5:30


18,344 Characters

Download Date

May 14, 2025, 11:37 PM GMT+5:30

File Name

Course_Report_yazdan_Rizvi.pdf

File Size

692.9 KB

Page 1 of 36 - Cover Page Submission ID trn:oid:::17268:95906171


Page 2 of 36 - AI Writing Overview Submission ID trn:oid:::17268:95906171

0% detected as AI Caution: Review required.

The percentage indicates the combined amount of likely AI-generated text as It is essential to understand the limitations of AI detection before making decisions
well as likely AI-generated text that was also likely AI-paraphrased. about a student’s work. We encourage you to learn more about Turnitin’s AI detection
capabilities before using the tool.

Detection Groups
0 AI-generated only 0%
Likely AI-generated text from a large-language model.

0 AI-generated text that was AI-paraphrased 0%


Likely AI-generated text that was likely revised using an AI-paraphrase tool
or word spinner.

Disclaimer
Our AI writing assessment is designed to help educators identify text that might be prepared by a generative AI tool. Our AI writing assessment may not always be accurate (it may misidentify
writing that is likely AI generated as AI generated and AI paraphrased or likely AI generated and AI paraphrased writing as only AI generated) so it should not be used as the sole basis for
adverse actions against a student. It takes further scrutiny and human judgment in conjunction with an organization's application of its specific academic policies to determine whether any
academic misconduct has occurred.

Frequently Asked Questions

How should I interpret Turnitin's AI writing percentage and false positives?


The percentage shown in the AI writing report is the amount of qualifying text within the submission that Turnitin’s AI writing
detection model determines was either likely AI-generated text from a large-language model or likely AI-generated text that was
likely revised using an AI-paraphrase tool or word spinner.

False positives (incorrectly flagging human-written text as AI-generated) are a possibility in AI models.

AI detection scores under 20%, which we do not surface in new reports, have a higher likelihood of false positives. To reduce the
likelihood of misinterpretation, no score or highlights are attributed and are indicated with an asterisk in the report (*%).

The AI writing percentage should not be the sole basis to determine whether misconduct has occurred. The reviewer/instructor
should use the percentage as a means to start a formative conversation with their student and/or use it to examine the submitted
assignment in accordance with their school's policies.

What does 'qualifying text' mean?


Our model only processes qualifying text in the form of long-form writing. Long-form writing means individual sentences contained in paragraphs that make up a
longer piece of written work, such as an essay, a dissertation, or an article, etc. Qualifying text that has been determined to be likely AI-generated will be
highlighted in cyan in the submission, and likely AI-generated and then likely AI-paraphrased will be highlighted purple.

Non-qualifying text, such as bullet points, annotated bibliographies, etc., will not be processed and can create disparity between the submission highlights and the
percentage shown.

Page 2 of 36 - AI Writing Overview Submission ID trn:oid:::17268:95906171


Page 3 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Faculty of Science and Engineering

Yazdan Abbas

Fintech, section B

Course Progress Reflection Report

April,2025

Department Financial Technology

Submitted To : Professor Faheem ur Rehman

Page 3 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171


Page 4 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Abstract

This report covers basic programming principles for novices, such as flowcharts, data types,

and input/output operations.The report covers several operators like Arithmetic, Incremen-

t/Decrement, Relational, logical, type casting, and Bitwise along with control structures like

conditional statements and loops. in order to support the modular coding techniques, report

includes discussion on functions, there default parameters, function overloading concepts etc.

Lastly, it discusses Arrays, Detailing on their initialization and Specific representation in pro-

gram. These subjects present a solid foundation that allows anyone to understand and apply

basic programming principles.

i
Page 4 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 5 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Plagiarism Declaration

With the exception of any statement to the contrary, all the material presented in this report is

the result of my own efforts. In addition, no parts of this report are copied from other sources.

I understand that any evidence of plagiarism and/or the use of unacknowledged third party

materials will be dealt with as a serious matter.

Signed Image

ii
Page 5 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 6 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Acknowledgements

I want to express my gratitude to my instructor, For all of their help and guidance and feedback

throughout this assignment. I also appreciate the support of my classmates, For their assistance,

any shared thoughts and encouragement.

iii
Page 6 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 7 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Contents

1 Introduction 1

1.1 What is programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.1.1 The Programming Process . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 Flowcharts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.2.1 purpose of flowcharts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Basic FlowChart 4

2.0.1 Basic Flowcart Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 Data Types 6

3.0.1 Primitive Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3.0.2 Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3.0.3 Hello World Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3.0.4 Signed and Unsigned Data Types . . . . . . . . . . . . . . . . . . . . . . . 8

3.0.5 Variables and Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

4 Operators 9

4.0.1 Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4.0.2 Pre/Post Increment and Decrement Operators . . . . . . . . . . . . . . . 9

4.0.3 Relational Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4.0.4 Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4.0.5 Type Casting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

5 Bitwise operators 12

6 Conditional/Selection Structures 14

iv
Page 7 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 8 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
CONTENTS CONTENTS

6.0.1 if, if...else . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

6.0.2 Nested if...else . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

6.0.3 if...else if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

6.0.4 Switch Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

6.0.5 Ternary Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

7 Loops 17

7.0.1 While loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

7.0.2 For loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

7.0.3 Do-while loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

7.0.4 Nested for loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

7.0.5 Break and Continue Statements . . . . . . . . . . . . . . . . . . . . . . . . 18

8 Functions 20

8.0.1 Function Definition and Calling . . . . . . . . . . . . . . . . . . . . . . . . 20

8.0.2 Function Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

8.0.3 Default Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

9 Arrays 22

9.0.1 Array Initialization and Representation . . . . . . . . . . . . . . . . . . . 22

9.0.2 Character Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

References 24

v
Page 8 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 9 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

List of Figures

1.1 program’s workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2.1 Basic Flow Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.2 problem visualization withb basic symbols . . . . . . . . . . . . . . . . . . . . . . 5

3.1 Data-Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3.2 Hello world . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4.1 Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4.2 Increment and Decrement Operators . . . . . . . . . . . . . . . . . . . . . . . . . 9

4.3 Relational Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4.4 Logical operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

vi
Page 9 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 10 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

List of Tables

3.1 Signed and Unsigned Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3.2 Variables and Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

vii
Page 10 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 11 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Listings

3.1 A simple C++ program that prints ”Hello, World!” to the screen . . . . . . . . . 7

4.1 TYPE CASTING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

5.1 Bitwise AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

5.2 Bitwise OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

5.3 Bitwise XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

5.4 Bitwise NOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

5.5 Bitwise Left Shift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

5.6 Bitwise Right Shift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

6.1 conditional statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

6.2 if , if... else . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

6.3 Nested if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

6.4 if...else if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

6.5 Switch statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

6.6 Ternary operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

7.1 while loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

7.2 For loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

7.3 Do-While Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

7.4 Nested for Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

7.5 Break-continue Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

8.1 Function prototype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

8.2 Function Definition and Calling . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

8.3 Function Over-Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

8.4 Default Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

9.1 Arrays initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

viii
Page 11 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 12 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
LISTINGS LISTINGS

9.2 Arrays accessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

9.3 Character Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

9.4 Arraysc ode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

ix
Page 12 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 13 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Chapter 1

Introduction

1.1 What is programming

Programming, or as we say coding, is writing a computer understandable instructions that we

execute or as say run to perform specific tasks or solve problems. The instructions are termed as

code, are written in different languages such as C, C++, Python, Java, etc. programming is an

art of transforming human ideas and creativity into a set instructions which are interpreted by

machines. The goal of programming is to develop a software which can automate tasks, manage

data, security, processing of information to computing the information, from simple calculations

to human computer interactions. Program is a unit of programming in simple words, program

is the series of instructions or commands that tells the computer what to do in order to achieve

a specific goal, weather it is mathematical problem, equations, pre-processing of images to

classification or regression, from simple home works to running websites, programming is the

heart of computer.

1.1.1 The Programming Process

Below is the simple process of programming, Fisrt we have to find the problem,then we do the

rest of the steps trying to get a optimum solution for that problem in terms of both time and

space when it comes to programming.

• Problem identification

• Designing the Algorithm

1
Page 13 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 14 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
1.2. Flowcharts Chapter 1. Introduction

• Coding

• Testing and debugging

• Deployment

Figure 1.1: program’s workflow

1.2 Flowcharts

Flowcharts are the visual representations of process / algorithm. Flowchart is an effective way

of demonstrating the overview of the algorithm which is being used as a solution to certain

problem at hand in a program. It uses arrows, lines, shapes like circle, rectangles, and dia-

monds to explain the sequence of the algorithm or a process.

2
Page 14 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 15 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 1. Introduction 1.2. Flowcharts

1.2.1 purpose of flowcharts

• Flowcharts simplify the complexity of a program.

• Flowcharts are standard visual language which is being understand by anyone specially

when it comes to businesses, or software engineering documents and teams.

• For a standard documentation of operations, flowcharts make it easier to train the new

team member / employee to further continue the procedure.

• Flowcharts increases the visualization of the problem, which results in data-driven choices.

3
Page 15 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 16 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Chapter 2

Basic FlowChart

2.0.1 Basic Flowcart Symbols

For the start one should know about the placcemnet and basic flow symbols, using the basic

symbols you can create and visualize any programming process. Here are some basic symbols

and terminologies one should know about the flowcharts.

Figure 2.1: Basic Flow Symbols

Now let’s see how you can solve and visualize a big problem with these basic symbols.

4
Page 16 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 17 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 2. Basic FlowChart

Figure 2.2: problem visualization withb basic symbols

5
Page 17 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 18 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Chapter 3

Data Types

In programing, data type refers to the kind of value a variable have, the standard data type

are Boolean, byte, short, int, long, float, double, and char in programing each for specific data

variable.

Name variable : takes a string

Age variable : is an integer

Date variable : in date format and so on.

3.0.1 Primitive Data Types

The present day data types, basic values of specific properties, independent of all the other

types are called primitive data types.

Figure 3.1: Data-Types

6
Page 18 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 19 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 3. Data Types

3.0.2 Input/Output

For most programs to communicate with the outside world, input/output (I/O) activities are

necessary. Programs receive data (input) and send data (output).

INPUT

The data user enters and provides by external systems to program is called ”input”. It can

come from various sources, such as the keyboard, a file, or network resources.

OUTPUT

The data that is sent back to user by the program to external system is called ”output”, It is

displayed on the screen, can be written into a file, or sent over a network.

3.0.3 Hello World Program

Listing 3.1: A simple C++ program that prints ”Hello, World!” to the screen
1 # include < iostream > // Library to include input - output functions
2 using namespace std ;
3

4 int main () {
5 cout << " Hello , ␣ World ! " << endl ; // Output to the screen
6 return 0; // Exit program
7 }

Figure 3.2: Hello world

7
Page 19 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 20 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 3. Data Types

3.0.4 Signed and Unsigned Data Types

Table 3.1: Signed and Unsigned Data Types

Feature Signed Data Type Unsigned Data Type


Definition Can store both positive and neg- Stores only non-negative values.
ative values.
Example Data int unsigned int
Type
Typical Range −32,768 to 32,767 (for 16-bit 0 to 65,535 (for 16-bit unsigned
int) int)
Default Behavior Most data types are signed by de- Must be explicitly declared as
fault. unsigned.
Use Cases When negative values are When only positive values are re-
needed. quired (e.g., counting items).

3.0.5 Variables and Constants


Table 3.2: Variables and Constants

Feature Variables Constants


Definition Data that can change during ex- Data whose value cannot be
ecution. changed once set.
Mutability Can be modified. Cannot be modified.
Example (C++) float number = 25.5; const float PI = 3.1415;
Purpose Hold dynamic or changing val- Hold fixed values like settings or
ues. formulas.
Use Cases User input, counters, temporary Mathematical constants, fixed
calculations. configurations.

8
Page 20 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 21 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Chapter 4

Operators

Operators are the construct of programing language that gives the functionalities which is not

possible to define by the user-defined function in a code.

4.0.1 Arithmetic Operators

For basic mathematical performed on values and variables we use Arithmetic Operators.

Figure 4.1: Arithmetic Operators

4.0.2 Pre/Post Increment and Decrement Operators

To increase or decrease the value of a variable by one increment (++) and decrement (–)

operators are used.

Figure 4.2: Increment and Decrement Operators

9
Page 21 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 22 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 4. Operators

Pre-increment/decrement (++x, –x): Value of variable is updated initially, and the expres-

sion then uses the revised value.

Post-increment/decrement (x++, x–): the expression then uses the initial value of the

variable before updating it.

4.0.3 Relational Operators

When we have to compare 2 values or expression Ralational Operators are used, the return

boolean result either true or false.

Figure 4.3: Relational Operators

4.0.4 Logical Operators

Boolean expressions can be combined or invert using Logical operators. They evaluate logical

conditions and return true or false based on the logic applied.

Figure 4.4: Logical operators

Logical AND: if both conditions are true, it returns true. Example: (a > 0 ∧ b > 0)

Logical OR: if at least one condition is true, it returns true. Example: (a > 0 ∨ b > 0)

Logical NOT: Inverts the truth value. Example: ¬(a > 0)

10
Page 22 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 23 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 4. Operators

4.0.5 Type Casting

In programming, specific types in being held by the variables, such as integers, floating-point

numbers, strings, and more. Computer interpretation and manipulation of the information is

determined by these data types. So Type casting becomes necessary when you want to perform

operations or assignments involving different data types. The method of converting one data

type into another is called Type casting.There is different syntax in different languages.

Listing 4.1: TYPE CASTING


1 int value = 12;
2 double doubleVal = value ; // Implicit type casting
3 }

11
Page 23 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 24 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Chapter 5

Bitwise operators

Bitwise operators are one of the most important operators in programming.Bitwise operators

manipulate the individual bits of integers. They are AND, OR, XOR, NOT, left and right

shifts.

Listing 5.1: Bitwise AND


1 int z = 89 , y =34 ;
2 int result = z & y ; // 0101 & 0011 = 0001 (1)
3 cout << " AND : " << result << endl ;

Listing 5.2: Bitwise OR


1 int r = 7 , s = 10;
2 int result_or = a | b ; // 0101 | 0011 = 0111 (7)
3 cout << " OR : " << result << endl ;

Listing 5.3: Bitwise XOR


1 int t = 8 , i = 10;
2 int result_xor = t ^ i ; // 0101 ^ 0011 = 0110 (6)
3 cout << " XOR : ␣ " << result << endl ;

Listing 5.4: Bitwise NOT


1 int p = 17;
2 int result = ~ p ; // ~0101 = ...11111010 ( in 2 ’ s complement : -6)
3 cout << " NOT : ␣ " << result << endl ;

12
Page 24 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 25 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 5. Bitwise operators

Listing 5.5: Bitwise Left Shift


1 int y = 12;
2 int result_ls = y << 1; // 0101 << 1 = 1010 (10)
3 cout << " Left ␣ Shift : ␣ " << result << endl ;

Listing 5.6: Bitwise Right Shift


1 int l = 13;
2 int result_rs = l >> 1; // 0101 >> 1 = 0010 (2)
3 cout << " Right ␣ Shift : ␣ " << result << endl ;

13
Page 25 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 26 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Chapter 6

Conditional/Selection Structures

if statement:evaluates a condition in a program and the particular is executed if the condition

is true.

Listing 6.1: conditional statement


1 int x = 20;
2 if ( x > 18) {
3 cout << " x ␣ is ␣ greater ␣ than ␣ 18 " << endl ;
4 }

6.0.1 if, if...else

In if, if....else , the else statement is executed when if statement is not true.

Listing 6.2: if , if... else


1 if ( y > 12) {
2 cout << " y ␣ is ␣ greater ␣ than ␣ 12 " << endl ;
3 } else {
4 cout << " y ␣ is ␣ not ␣ greater ␣ than ␣ 12 " << endl ;
5 }

6.0.2 Nested if...else

When 1 if is nested inside the another if statement, let’s see the example.

Listing 6.3: Nested if

14
Page 26 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 27 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 6. Conditional/Selection Structures

1 if ( r > 0) {
2 if ( r == 10) {
3 cout << " r ␣ is ␣ equal ␣ to ␣ 10 " << endl ;
4 }
5 }

6.0.3 if...else if

When we have to check Multiple possibilities in sequence then we apply the chain of if ... else

if.

Listing 6.4: if...else if


1 if ( i > 20) {
2 cout << " i ␣ is ␣ greater ␣ than ␣ 20 " << endl ;
3 } else if ( i > 15) {
4 cout << " i ␣ is ␣ greater ␣ than ␣ 15 ␣ but ␣ less ␣ than ␣ or ␣ equal ␣ to ␣ 20 " << endl
;
5 } else {
6 cout << " i ␣ is ␣ less ␣ than ␣ or ␣ equal ␣ to ␣ 15 " << endl ;
7 }

6.0.4 Switch Statement

A multi-way branch statement whcih is used for a particular checking one condition against

multiple possibilities.

Listing 6.5: Switch statement


1 switch ( day ) {
2 case 1:
3 cout << " tuesday " << endl ;
4 break ;
5 default :
6 cout << " Invalid ␣ day " << endl ;
7 }

15
Page 27 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 28 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 6. Conditional/Selection Structures

6.0.5 Ternary Operator

shorthand for if...else which based on condition returns one of two values.

Listing 6.6: Ternary operator


1 result = ( t > 12) ? " t ␣ is ␣ greater ␣ than ␣ 12 " : " t ␣ is ␣ less ␣ than ␣ or ␣ equal ␣
to ␣ 12 " ;

16
Page 28 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 29 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Chapter 7

Loops

Loops are the most basic yet powerful concepts in programming. A loop in a computer program

is an instruction that repeats until a specified condition is reached. The loop asks a question,

If the answer requires action, it is executed.

7.0.1 While loop

While loop (Sentinel-controlled and condition-controlled): Runs as long as a given

condition for it is true,so that’s why while loop is suitable for both sentinel-controlled and

condition-controlled loops. We mostly apply the condition on the input taken by the user.

Listing 7.1: while loop


1 int Age ;
2 while ( Age != 0) {
3 cin >> Age ;
4 }

7.0.2 For loop

When it comes to iterations for loop is used, it iterates till the condition is true, and terminates

as soon as the condition gets false.post and pre increment and decrement is used in the for loop

as:

17
Page 29 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 30 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 7. Loops

Listing 7.2: For loop


1 for ( int j = 0; j < 20; j ++) {
2 cout << " Iteration ␣ " << j << endl ;
3 }

7.0.3 Do-while loop

the do-while loop is executed at least once and then the condition is checked , as:

Listing 7.3: Do-While Loop


1 int c = 0;
2 do {
3 cout << " Iteration ␣ " << c << endl ;
4 i ++;
5 } while ( c < 10) ;

7.0.4 Nested for loops

When it comes to mutidimential data , nested for loop is used. when we do multi dimensional

maths calculations e.g matrix multiplication, addition, substraction e.t.c

Listing 7.4: Nested for Loop


1 for ( int j = 0; j < 6; j ++) {
2 for ( int k = 0; k < 6; k ++) {
3 cout << j << " ," << k << endl ;
4 }
5 }

7.0.5 Break and Continue Statements

• break exits the loop prematurely.

• continue skips the current iteration and proceeds to the next iteration.

18
Page 30 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 31 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 7. Loops

Listing 7.5: Break-continue Statement


1

2 for ( int v = 0; v < 10; v ++) {


3 if ( v == 8) break ;
4 }

19
Page 31 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 32 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Chapter 8

Functions

Functions are ”self contained” part of program , which is executed to complete a specific task.

Functions usually ”take in” data, process it, and ”return” a result.fucntions are important as

they make program ”optimal” as you do not have to write the logic again and again , Once a

function is written, it get called and take in data and make the time space efficient.

Listing 8.1: Function prototype


1 int add ( int , int ) ; // Function prototype

8.0.1 Function Definition and Calling

Functions have a return type, a name, and parameters, and are get called in the main program.

Listing 8.2: Function Definition and Calling


1 int add ( int z , int v ) {
2 return z + v ;
3 }
4 \\
5 \\
6 \\

8.0.2 Function Overloading

Function overloading, means when multiple functions can have the same name with different

parameters:

20
Page 32 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 33 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 8. Functions

Listing 8.3: Function Over-Loading


1 int add ( int w , int v ) {
2 return w + v ;
3 }
4

5 double add ( double f , double g ) {


6 return f + g ;
7 }
8

9 int main () {
10 int num1 = add (12 , 10) ;
11 double num2 = add (7.8 , 9.6) ;
12 cout << " Int : ␣ " << num1 << " \ n " ;
13 cout << " Double : ␣ " << num2 ;
14 return 0;
15 }

8.0.3 Default Parameters

Functions can have default parameters values, which are used if no argument is passed. One can

use a default parameter value, by using the equals sign (=) and is often known as an ”optional

parameter.

Listing 8.4: Default Parameters


1 void myFun ( string my_country = " pakistan " ) {
2 cout << my_country << " \ n " ;
3 }
4

5 int main () {
6 myFun ( " Sweden " ) ;
7 myFun ( " India " ) ;
8 myFun () ;
9 myFun ( " USA " ) ;
10 return 0;
11 }

21
Page 33 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 34 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

Chapter 9

Arrays

An array is a data structure which is collection of elemeents can be values or variables and each

value and variable is identified by at least one array index or key.

9.0.1 Array Initialization and Representation

Arrays are initialized and representated as

Listing 9.1: Arrays initialization


1 int arrays [7] = {1 , 2 , 3 , 4 , 5 ,6 ,7}; // or

Listing 9.2: Arrays accessing


1 int arrays [7] = {1 , 2 , 3 , 4 , 5 ,6 ,7}; // or
2 cout << arrays [0]; // Outputs 1

9.0.2 Character Arrays

Character arrays are used to store strings.

Listing 9.3: Character Arrays


1 char names [] = " yazdan " ; // Automatically adds ’\0 ’ at the end

here’s to clear describtion

22
Page 34 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 35 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 9. Arrays

Listing 9.4: Arraysc ode


1 # include < iostream >
2 using namespace std ;
3 int main () {
4 // Integer Array Initialization
5 int num [6] = {11 , 12 , 16 , 40 , 20 , 50};
6 // Displaying array elements
7 cout << " Array ␣ Elements ␣ integers : ␣ " ;
8 for ( int j = 0; j < 6; j ++) {
9 cout << num [ j ] << " ␣ " ;
10 }
11 cout << endl ;
12 // Character Array ( String )
13 char names_here [] = " yazdan " ;
14 // Displaying character array
15 cout << " Names : ␣ " << name_here << endl ;
16 return 0;
17 }

23
Page 35 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Page 36 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171
Chapter 9. Arrays

Referencing

• Programming 1.1, https://www.geeksforgeeks.org/programming-tutorial/

• Flowchart Purpose 1.2, https://www.geeksforgeeks.org/an-introduction-to-flowcharts/

• Basic Flowchart 2, https://www.programiz.com/article/flowchart-programming

• Basic Flow Symbols 2.1,https://www.geeksforgeeks.org/an-introduction-to-flowcharts/

• Problem visualization 2.2,https://www.tutorialspoint.com/programming_methodologies/

programming_methodologies_flowchart_elements.htm

• Logical Operators 4.0.4,https://www.w3schools.com/programming/prog_operators_logical.

php

• Functions 8,https://users.cs.utah.edu/~germain/PPS/Topics/functions.html

• Bitwise operators 5,https://www.tutorialspoint.com/cprogramming/c_bitwise_operators.

htm

• Loops 7,https://www.thoughtco.com/definition-of-loop-958105

• Function 8,https://users.cs.utah.edu/~germain/PPS/Topics/functions.html

• Function-over loading 8.0.2,https://www.w3schools.com/cpp/cpp_function_overloading.

asp

• Default Paeameter 8.0.3,https://www.learncpp.com/cpp-tutorial/default-arguments/

• Arrays 9,

https://press.rebus.community/programmingfundamentals/chapter/arrays-and-lists/

24
Page 36 of 36 - AI Writing Submission Submission ID trn:oid:::17268:95906171

You might also like