CC-112L Programming Fundamentals Laboratory 01 Introduction To Programming, Algorithms and C
CC-112L Programming Fundamentals Laboratory 01 Introduction To Programming, Algorithms and C
Programming Fundamentals
Laboratory 01
Version: 1.0.0
Contents:
• Learning Objectives
• Required Resources
• General Instructions
• Background and Overview
o Program
o Algorithm
o Pseudocode
o Flowchart
• Activities
o Pre-Lab Activity
▪ Microsoft ® Visual Studio 2022 installation
▪ LARP installation
o In-Lab Activity
▪ Pseudocode
– New Project
– Display Output on Console
– Read & Display Output on Console
– Read Multiple Inputs
– IF ELSE Statements
– Loop Statements
▪ Flowchart
– Symbols
– IF ELSE Conditional
– FOR Loop Statement
– Save File in LARP
▪ C Program
– Simple Program in Microsoft ® Visual Studio –
Operators in C
– Operators Precedence in C
– Integer Division
▪ Task 01 (a): Pseudocode
▪ Task 01 (b): Pseudocode
▪ Task 02: Flowchart
▪ Task 03: Visual Studio
o Post-Lab Activity
▪ Task 01: Flowchart
• Submissions
• Evaluations Metric
• References and Additional Material
• Lab Time and Activity Simulation Log
Learning Objectives:
• Pseudocode
• Input/Output
• Arithmetic Expressions
• Flowcharts
• C Operators
• Operator Precedence
• C Program Development Environment
Resources Required:
• Desktop Computer or Laptop
• LARP 3.0 Software
• Microsoft ® Visual Studio 2022
General Instructions:
• In this Lab, you are NOT allowed to discuss your solution with your colleagues, even not
allowed to ask how is s/he doing, this may result in negative marking. You can ONLY
discuss with your Teaching Assistants (TAs) or Lab Instructor.
• Your TAs will be available in the Lab for your help. Alternatively, you can send your queries
via email to one of the followings.
Teachers:
What is an Algorithm?
An algorithm is a finite set of instructions used to solve a particular task. Everything we do follows an
algorithm. So, computer algorithms are instruction manuals that tells computer how to perform a task.
Pseudocode:
Pseudocode is a of an algorithm in human readable form that does not requires any programming
language. It summarizes the flow in which program executes.
Flowchart:
A flowchart is a pictorial representation (diagram / visual representation) of an algorithm, or process
in a sequential order.
Microsoft ® Visual Studio is an integrated development environment (IDE) from Microsoft. It is used
to develop computer programs, as well as websites, web apps, web services and mobile apps.
Microsoft ® Visual Studio supports 36 different programming languages and allows the code editor
and debugger to support nearly any programming language, provided a language-specific service
exists. Built-in languages include C, C++, C++/CLI, Visual Basic, .NET, C#, F#, JavaScript,
TypeScript, XML, XSLT, HTML, and CSS. Support for other languages such as Python, Ruby,
Node.js, and M among others is available via plug-ins. Java (and J#) were supported in the past.
© https://en.wikipedia.org/wiki/Microsoft_Visual_Studio
LARP:
LARP's main advantage over traditional programming languages is its flexible and semi natural
syntax, allowing one to formulate algorithms without the impediments of cryptic languages such as C,
C++, Pascal or Java.
© http://larp.marcolavoie.ca/en/description/description.htm
Activities:
Pre-Lab Activities:
Microsoft ® Visual Studio 2022 Installation:
• Open Web browser and in search bar, type “Visual Studio”, Open the first site or • Type
the URL https://visualstudio.microsoft.com in the address bar of the Web browser
Fig. 01 (Microsoft ® Visual Studio Installation)
• Under “Meet the Visual Studio family” heading, click “Download Visual Studio” dropdown
menu
• Click “Community 2022”. The Visual Studio Setup will be downloaded. • Run
the “Visual Studio Setup” file. Visual Studio Installer will be downloaded.
In-Lab Activities:
Pseudocode
New Project:
• On the text editor in LARP, type “WRITE {expression}” OR drag the “WRITE
{expression_list}” template from the “Templates” column
• Replace the expression list with your desired text within inverted commas •
On the ribbon, click the execute button OR press “F7” key
• On the text editor in LARP, type “READ {variables}” OR drag the “READ {variable_list}”
template from the “Templates” column
• Replace the variable list with your desired variable name
• On the next line type “WRITE” following with an expression and comma separated variable name
• On the ribbon, click the execute button OR press “F7” key
Fig. 13 (Pseudocode in LARP)
• Enter the input value on the console
• Press “Enter” key. Output will be displayed
• On the text editor in LARP, type “READ {variables}” OR drag the “READ {variable_list}”
template from the “Templates” column
• Replace the variable list with your desired comma separated variable names • On
the next line type “WRITE” following with comma separated variable names • On
the ribbon, click the execute button OR press “F7” key
IF ELSE Statement:
The IF/ELSE statement executes a block of code if a specified condition is true. If the condition is
false, another block of code can be executed.
• Drag “IF {condition} THEN {instructions} ELSE IF {condition} THEN {instructions} ENDIF”
on text editor from “Templates” column
• Write a code which read a number from user and then prints the number in text form as shown in
figure
Loop Statements:
A Loop executes series of statements repeatedly for a specified number of times or until specified
conditions are met.
• Drag “WHILE {condition} DO {instructions} ENDWHILE” on the text editor from the
“Templates” box
• Replace the condition & instruction so that console prints numbers from 1 to 5 • Similarly drag
“FOR {variable} = {initial value} TO {final value} DO {instructions} ENDFOR” • Replace the
values & instruction so that console prints numbers from 6 to 10
Flowchart
Symbol Name Function
Input / Output:
• Read a number from user with variable name “Num” using Input/Output symbol •
Drag IF ELSE Conditional from the “Templates” box
• Display “Greater than 5” if the condition is true else display “Less than or equal to 5”
Laboratory 01 – Introduction to Programming, Algorithms and C Page 17 of 31
CC-112L Programming Fundamentals SPRING 2021
A FOR Loop is a statement for specifying iteration, which allows the code to be executed
repeatedly. • Drag FOR Loop template from the “Templates” box
Laboratory 01 – Introduction to Programming, Algorithms and C Page 18 of 31
CC-112L Programming Fundamentals SPRING 2021
Operators in C:
Operator Type Name Operator
Decrement --
Arithmetic Addition +
Operators
Subtraction -
Multiplication *
Division /
Modulus %
NOT !
Equal to ==
Not Equal to !=
Bitwise OR |
Bitwise XOR ^
Bitwise Complement ~
Operator Precedence in C:
Operator precedence determines the grouping of terms in an expression and decides how an
expression is evaluated. Operators with highest precedence appear at the top of the table, those with
lowest appear at the bottom.
Unary +, -, !, ~, ++, --
Multiplicative *, /, %
Additive +, -
Bitwise XOR ^
Bitwise OR |
Logical OR ||
Conditional ?:
Integer Division:
Division in which the fractional part is discarded is called Integer Division. For example 11/2
= 5 + ½. In Integer Division, 11/2 = 5. Demonstration in C programming is shown below.
Task 01: Pseudocode [35 minutes / 30 marks] Part (a): [15 minutes / 10 marks] Write a
Pseudocode in LARP software which:
• Reads a number as an input from user
• Check if the number is positive or negative
• Displays “Number is positive” in case of positive number and “Number is negative” in case of
negative number
Part (b): [20 minutes / 20 marks] Write a Pseudocode in LARP software which:
Post-Lab Activities:
Task 01: Flowchart [Estimated 30 minutes / 30 marks] Create a Flowchart in LARP software
which:
e.g., if your Roll No is “6” then 10 prime numbers which your program finds will be “7, 11, 13, 17...”
• Sum the Prime Numbers
• Displays the “Sum” on the console
• Submit “.larp” file named your “Roll No” on Google Classroom
Submissions:
• For In-Lab Activity: Save the files on your PC. TA’s will evaluate the tasks offline. • For
Post-Lab Activity: Submit the .larp file on Google Classroom and name it to your roll no.
Evaluations Metric:
• All the lab tasks will be evaluated offline by TA’s
• Division of In-Lab marks: [50 marks] ▪ Task 01 Part (a): Pseudocode [10 marks] ▪
Task 01 Part (a): Pseudocode [20 marks] ▪ Task 02: Flowchart [15 marks] ▪ Task03:
Visual Studio [05 marks]
• Division of Post-Lab marks: [30 marks] ▪ Task01: Flowchart [30 marks]
• LARP Documentation
http://larp.marcolavoie.ca/en/documentation/documentation.htm