Lab No 1
Lab No 1
Lab No 1
Programming
Fundamentals
CSC-113
FALL 2024
RUBRICS GUIDELINE FOR SOFTWARE BASED LAB
RUBRIC-LABORATORY MANUAL
Course Name (Course Code), ______________________Semester, Batch_____________
Name of Student: _______________________________ Roll No. __________________
Score Sheet
Lab
Digital Problem Solving Evaluation Lab Total
Competencies Skills Results Manual Score
Lab (3) (3) (3) (1) (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Total
TABLE OF CONTENTS
WEEKS EXPERIMENTS
4 Arithmetic Operators
Logical operators
Relational operator
Decision Making
One way if statements, If-else statements
5 Nested if statements
Common errors in selection statements.
Switch cases
Iterations using loops
For ()
While ()
6
do while ()
nested Loop ()
infinite loop ()
Arrays:
Single
7
Double
Multidimensional
8 String Operations and Manipulation
9,10 Function
Simple functions
Function that returns a value
Using arguments to pass data to a function
User defined function
Using more than one function
Global & local (scope)
Prototype VS classical K and R
Preprocessor Directives
11 Recursion
Pointers
Pass by val & by ref
Returning data from functions
12,13 Pointers and arrays
Pointers and strings
Lab Manual
Double Indirection: Pointers to pointers
Pointer to functions
Structures and Unions.
14
Making header file
15 Programming
Final Project Presentation
Fundamentals
CSC-113
LAB 01
FALL 2024
Table of Content
Lab Objective
No#
1 1. Programming Languages
● Understand the concept, importance, and types of programming
languages.
● Discuss the evolution and history of programming languages,
highlighting key milestones.
2. C Programming Language
● Gain an overview of C, its history, and significance.
● Learn basic syntax and structure; develop simple programs to
practice fundamental concepts.
3. Translators
● Define translators and their role in code conversion.
● Differentiate between assemblers, compilers, and interpreters;
understand program translation and execution.
4. Types of Translators
● Assemblers: Convert assembly language code into machine
code.
● Compilers: Translate high-level languages into machine code,
focusing on efficiency and error-checking.
● Interpreters: Execute code line-by-line, emphasizing flexibility
and debugging ease.
5. Algorithms
● Define algorithms and their significance in problem-solving and
programming.
● Learn characteristics of good algorithms; develop simple
algorithms for practice.
6. Flowcharts
● Understand flowcharts and their role in representing algorithms
visually.
● Learn standard symbols; create flowcharts to visualize program
logic.
7. Pseudocode
● Define pseudocode and its role in bridging algorithms and
coding.
● Learn writing conventions; develop pseudocode for detailing
logic and steps in a language-independent manner.
Lab 1
Lab 1
Objective:
The objective of this lab is to give introduction to:
Programming Languages:
C Programming Language:
1. Gain a comprehensive overview of the C programming language, its history, and its
significance.
2. Learn the basic syntax and structure of C programs.
3. Develop simple C programs to practice fundamental concepts like variables, data types,
and control structures.
Translators:
1. Define what translators are in the context of programming and their role in converting
code.
2. Differentiate between the main types of translators: assemblers, compilers, and
interpreters.
3. Understand the process of translation and execution of programs through these
translators.
Types of Translators:
1. Assemblers: Learn how assemblers convert assembly language code into machine code.
2. Compilers: Study how compilers translate high-level programming languages into
machine code, focusing on their efficiency and error-checking capabilities.
3. Interpreters: Explore how interpreters execute high-level programming languages by
translating code line-by-line, emphasizing their flexibility and ease of debugging.
Algorithms:
1. Understand what flowcharts are and how they visually represent algorithms.
2. Learn the standard symbols used in flowcharts and their meanings.
3. Create flowcharts for various algorithms to practice visualizing the logical flow of a
program.
Pseudocode:
1. Define pseudocode and its role in bridging the gap between algorithms and actual coding.
2. Learn the conventions and structure of writing pseudocode.
3. Develop pseudocode for simple algorithms to practice detailing the logic and steps of a
solution in a language-independent manner.
Are you aiming to become a Software engineer one day? Do you also want to develop an
application for Solving Problems that People worldwide would love to use? Are you passionate
enough to take the big step to enter the programming world? Then you are in the right place. In
this article, you will get a brief Introduction to Programming Languages. You will understand the
following pointers:
1. What is Software?
2. Types of Software
3. What is a Language?
Program: A Program is a common computer term executed by software that runs on a computer
when the program is used as what it means to create a software program. The set of instructions
is called a program. For Example, Programmers create programs by writing code that instructs
the computer what to do and execute it on a special software designed for it, such as turbo C for
executing ‘C’ Programs.
What is Software?
Software refers to a collection of data, programs, procedures, and instructions that tell a
computer how to work. This is in contrast to physical hardware, from which the system is built
and actually performs the work. So, Software is a collection of programs that uses the resources
of the Hardware components. A Program is a set of instructions designed for a particular task.
The set of programs is called software. Let us understand this with an example, i.e., Calculator.
For each button, there is some program written inside it. That means a calculator is a collection
of programs. And we can also say that a Calculator is software. So, the software is a collection of
programs.
What is a Language?
Generally, languages are used to communicate with others. The languages like Odia / English /
Marathi / Hindi are called human/regional languages used to communicate with humans.
Computer languages are used to write the programs [software] to communicate with the
machines
Computer languages are the means by which computers are instructed to perform specific tasks.
They vary greatly in syntax, level of abstraction, and specific use cases. Here’s an overview of
the different types of computer languages: Basically, computer languages are divided into 3
types.
Machine Language:
● Description: The most basic type of computer language, consisting of binary code (0s
and 1s). It is directly understood by the computer’s central processing unit (CPU).
Assembly Language:
High-Level Languages:
More abstract and closer to human languages, high-level languages are easier to read, write, and
maintain. They are platform-independent and require a compiler or interpreter.
Examples:
● Functional Programming Languages: Like Haskell, Scala, and Erlang, emphasizing the
application of functions.
● Scripting Languages: Used for automating tasks, including Python, Perl, and JavaScript.
C is a high-level language with low-level features. Hence, C is also called middle-level language.
High-level features allow designing application software like calculator, calendar, media player,
etc.; low-level features are used to design system software like OS, device drivers, and
translators. etc. Hence, C is multi-purpose. C is a high-level/middle-level programming
language.
The languages are used to communicate with others. Computer languages are used to write the
programs [software] to communicate with the machines.
The High-Level Programming Languages are syntactically similar to English and easy to
understand. High-Level Programming Languages are user-dependent languages. A High-Level
Programming Language combines alphabets, digits, and symbols. It is called micro statements.
By using a high-level programming language, we are developing user interface applications.
Examples: C, C++, VC++, JAVA, C#, Swift, Objective C, D-Language
Low-level programming languages are computer languages with a very small degree of
abstraction from a computer’s machine code or architecture. They are closer to the hardware than
high-level programming languages, making them more complex and harder for humans to
understand, but they offer greater control over the hardware.
The Low-Level Programming Languages are the languages that can be easily understandable to
the system. These are system-dependent languages. The two main categories of low-level
programming languages are as follows:
1. Machine Language
2. Assembly Language
Machine Language:
Machine Language is the fundamental language for the system. It can be directly understandable
without any translation. These are machine-oriented languages that use the collection of the
binary of 1’s and 0’s.
● Nature: This is the most basic level of programming language. Machine language
comprises binary code – a series of 0s and 1s.
● Direct Interaction: It allows direct interaction with the hardware and is specific to a
particular processor type. Programs written in machine language are executed directly by
the computer’s CPU.
● Usage: Due to its complexity and the need for precise hardware knowledge, machine
language is rarely used for programming in modern times, except in very specific
scenarios like bootloader or firmware programming.
Assembly Language:
The Assembly Language can be called Symbolic Language. To remember easily the program
coding be implementing this language. Different types of symbols will be used in this language
to design the program. However, this assembly code is not directly understandable to the system,
so we require translators.
● Mnemonic Codes: Assembly language uses short, mnemonic codes like ADD for
addition and SUB for subtraction, which are easier for humans to understand than binary
code.
● Assembler: Programs written in assembly language are converted into machine language
by a program called an assembler. This conversion process is relatively straightforward
as there is a direct correspondence between assembly language commands and machine
language instructions.
● Control and Efficiency: Assembly language provides more control over the hardware
than high-level languages. It allows programmers to utilize the full potential of the
hardware, achieving performance optimizations that are not possible in higher-level
languages.
● Usage: Commonly used in system programming, embedded systems, device drivers, and
situations where hardware interaction and performance are critical. However, it requires a
deep understanding of the computer architecture and is more error-prone and time-
consuming to write and maintain than high-level languages.
What is a Translator?
The user’s instructions are always in English, which is called source code. But the computer
cannot understand this source code, and the computer’s understandable code is binary / machine.
To convert this source code into binary code, we are using the interface software called
translators.
In programming, a translator is a software tool that converts code written in one programming
language into another language or into a form that a computer can execute. This process is
essential because programmers write code in high-level programming languages, but computers
can only execute instructions in their own machine language. The translators are classified into
three types:
Compiler and interpreter are both used to convert high-level programs to machine code.
Assembler is used to convert low-level programs to machine code.
Compiler:
A compiler is the system software that translates High-level programming language code into
binary format in a single step, except for those lines with an error. It checks all kinds of limits,
ranges, errors, etc.
● This translation is done all at once, creating an executable file that can be run
independently of the original source code.
● Since the entire code is converted and optimized at once, compiled programs often run
faster than interpreted ones.
Interpreter:
It is the system software that converts programming language code into binary format step by
step, i.e., line-by-line compilation takes place. It reads one statement and then executes it until it
proceeds further to all the statements. If an error occurs, it will stop the compilation process.
Development-wise, an interpreter is recommended to use.
● An interpreter translates and executes the source code line by line on the fly.
● It reads the source code, interprets it, and executes it directly without producing a
separate machine code file.
● This approach is generally slower than compilation because each line is translated during
execution, but it allows for more dynamic programming and quicker testing and
debugging.
Note: The compiler converts the total source code at once by leaving the error lines. At the same
time, the interpreter is line by line. C & C++ are compiler-based languages. Java / .Net / Python,
etc., are compiler-based interpreted languages.
Assembler:
It is the system software that converts assembly language instructions into binary formats. The
assembler’s working style is similar to the compiler.
Compilers, Interpreters, and Assemblers are all types of translators in programming, each serving
a distinct purpose in converting source code into a format that a computer can execute.
Understanding the differences between them is key for programmers. Here’s a detailed
comparison:
Compilers
● Function: Translates the entire source code of a high-level programming language into
machine code (or intermediate code) in one go.
● Execution: The output is an executable file or object code which can be run
independently from the original source code.
● Speed: Generally, results in faster execution of the final program because the translation
is done beforehand.
Interpreters
● Function: Translates high-level programming language into machine code on the fly,
executing line by line.
● Execution: No separate executable file is produced. The interpreter reads and executes
the code directly.
● Speed: Typically, slower execution than compiled programs because translation happens
during runtime.
● Use Cases: Common for scripting and dynamically typed languages like Python,
JavaScript, and Ruby.
● Debugging: It is easier to debug since it executes the code line by line and can stop
immediately upon encountering errors.
Assemblers
● Function: Translates assembly language, which is a low-level language but more human-
readable than machine code, into binary machine code.
● Speed: The output, being machine code, is very fast and efficient.
● Use Cases: Mainly used for systems programming and working closely with hardware.
The word Algorithm means” A set of finite rules or instructions to be followed in calculations or
other problem-solving operations”
Or
” A procedure for solving a mathematical problem in a finite number of steps that frequently
involves recursive operations”.
Algorithms play a crucial role in various fields and have many applications. Some of the key
areas where algorithms are used include:
1. Computer Science: Algorithms form the basis of computer programming and are used to
solve problems ranging from simple sorting and searching to complex tasks such as
artificial intelligence and machine learning.
2. Mathematics: Algorithms are used to solve mathematical problems, such as finding the
optimal solution to a system of linear equations or finding the shortest path in a graph.
3. Operations Research: Algorithms are used to optimize and make decisions in fields
such as transportation, logistics, and resource allocation.
5. Data Science: Algorithms are used to analyze, process, and extract insights from large
amounts of data in fields such as marketing, finance, and healthcare.
Algorithm for Making a Peanut Butter Sandwich
1. Start
o Peanut butter
o A butter knife
o A plate
6. Spread the peanut butter evenly on one slice of bread using the knife.
7. Place the other slice of bread on top of the peanut buttered slice.
11. End
1. Start
2. Initialize a variable sum to 0.
3. Initialize a variable count to the number of elements in the list.
4. Loop through each element in the list:
o Add the current element to sum.
5. Calculate the average by dividing sum by count.
6. Print the average.
7. End
Algorithm for Finding the Maximum Value in a List
1. Start
2. Initialize a variable max with the value of the first element in the list.
3. Loop through each element in the list starting from the second element:
4. After the loop ends, max will hold the largest number in the list.
5. Print max.
6. End
1. Pseudo code
2. Flowchart
What is a Pseudocode?
Pseudocode is a tool that can be used to write a preliminary plan for the development of a
computer program. It is a generic way of describing an algorithm without the use of any specific
programming language syntax. In fact, it serves as an English like way to state an algorithm.
Algorithm FindAverage
Begin
Set sum to 0
End For
Print average
End
Algorithm FindMaximum
Begin
End If
End For
Print max
End
What is a Flowchart?
Flowchart is a graphical representation of an algorithm. Programmers often use it as a program-
planning tool to solve a problem. It makes use of symbols which are connected among them to
indicate the flow of information and processing.
The process of drawing a flowchart for an algorithm is known as “flowcharting”.
● Decision Diamond symbol represents a decision point. Decision based operations such as
yes/no question or true/false are indicated by diamond in flowchart.
● Connectors: Whenever flowchart becomes complex or it spreads over more than one
page, it is useful to use connectors to avoid any confusions. It is represented by a circle.
● Flow lines: Flow lines indicate the exact sequence in which instructions are executed.
Arrows represent the direction of flow of control and relationship among different
symbols of flowchart.
2. Write a Pseudocode for adding, subtracting, multiply and divide two numbers
3. Write a pseudocode and draw a flowchart that reads in the radius and length of a
cylinder and computes the volume using the following formulas:
Area = radius2 * π
4. Write a pseudocode that converts pounds into kilograms. The program prompts the
user to enter a number in pounds, converts it to kilograms, and displays the result. One
pound is 0.454kilogram.