Fpl Lab Manual 2024 Part (1)
Fpl Lab Manual 2024 Part (1)
Practical Manual of
FUNDAMENTALS OF PROGRAMMING
(Course code: ESC-105-COM)
W.E.F. A.Y. 2024-2025
Name:
Class: Roll No.:
Branch: Div.:
Year: Exam Seat No.:
GURU GOBIND SINGH FOUNDATION’S
GURU GOBIND SINGH COLLEGE OF ENGINEERING AND
RESEARCH CENTRE, NASHIK
CERTIFICATE
DEPARTMENT OF BASIC ENGINEERING SCIENCE
Course Outcomes:
On completion of the course, students will be able to:
CO1: To Design algorithms for simple computational problems.
CO2: To Use mathematical, Logical Operators and Expressions.
CO3: To apply Control Flow structures for decision making.
CO4: To design a solution using Arrays, Character and String Arrays.
CO5: To Design and apply user defined functions.
CO6: To Apply structures in Problem solving using C programming language
1. To accept the number and Compute a) square root of number, b) Square of number, c) Cube of
number d) check for prime, d) factorial of number e) prime factors.
2. To accept from the user the number of Fibonacci numbers to be generated and print the
Fibonacci series.
3. To accept an object mass in kilograms and velocity in meters per second and display its
Momentum. Momentum is calculated as e=mc2 where m is the mass of the object and c is its
velocity.
4. In the array do the following: 1. Find a given element in array 2. Find Max element 3. Find Min
element 4. Find frequency of given element in array 5. Find Average of elements in Array.
5. Write a C program for employee salary calculation given, Basic, H.R.A. 20 % of Basic and D.A.
150 % of Basic.
6. To accept a student's marks for five subjects, compute his/her result. Student is passing if
he/she scores marks equal to and above 40 in each course. If student scores aggregate greater
than 75%, then the grade is distinguished. If aggregate is 60>= and <75 then the grade is second
division. If aggregate is 40>= and <50, then the grade is third division.
7. To accept two numbers from the user and compute the smallest divisor and Greatest Common
Divisor of these two numbers.
8. Write a C program that accepts a string from the user and performs the following string
operations- i. Calculate length of string ii. String reversal iii. Equality check of two Strings iii. Check
palindrome ii. Check substring.
9. Create Structure EMPLOYEE for storing details (Name, Designation, gender, Date of Joining and
Salary), and store the data and update the data in structure.
10. Create class STORE to keep track of Products (Product Code, Name and price). Display menu
of all products to users. Generate bills as per order.
Mini-Projects:
1. Calculator with basic functions. Add more functionality such as graphic user interface and
Complex calculations.
2. Program that simulates rolling dice. When the program runs, it will randomly choose a
number between 1 and 6 (Or other integer you prefer). Print that number. Request user to
roll again. Set the min and max number that dice can show. For the average die, that means a
minimum of 1 and a maximum of 6.
3. Guess Number: Randomly generate a number unknown to the user. The user needs to guess
what that number is. If the user’s guess is wrong, the program should return some sort of
indication as to how wrong (e.g. the number is too high or too low). If the user guesses
correctly, a positive indication should appear. Write functions to check if the user input is an
actual number, to see the difference between the inputted number and the randomly
generated numbers, and to then compare the numbers.
4. To calculate the salary of an employee given his basic pay (take as input from user).
Calculate gross salary of employee. Let HRA be 10 % of basic pay and TA be 5% of basic pay.
Let employees pay professional tax as 2% of total salary. Calculate net salary payable after
deductions.
GURU GOBIND SINGH FOUNDATION’S
GURU GOBIND SINGH COLLEGE OF ENGINEERING AND RESEARCH
CENTRE, NASHIK
FUNDAMENTALS OF PROGRAMMING
INDEX
Practical In-charge
EXPERIMENT NO: 1
TITLE: Write a C program for employee salary calculation given, Basic, H.R.A.
20% Basic and D.A. 150 % of Basic.
OBJECTIVES:
1. To study Decision Control Statements
2. To understand and apply if and else statements.
OUTCOMES:
After this experiment, students will acquire knowledge of decision control structures
in C and its application.
THEORY:
This assignment will read Basic Salary of an employee, calculate other parts of
the salary on percent basic and finally print the Salary of the employee. Here, we are
reading the basic salary of the employee, and calculating HRA, DA, salary of the
employee.
Variable:
In programming, a variable is a container (storage area) to hold data. To indicate the storage
area, each variable should be given a unique name.Variable names are just the symbolic
representation of a memory location.
ALGORITHM:
1. Declare all variables da, hra, gross.
2. Enter the salary from the user.
3. Perform calculation on basic salary when HRA is 20% and DA is 150%.
4. Calculate gross salary.
5. Display gross salary.
CONCLUSION:
TITLE: To accept from the user the number of Fibonacci numbers to be generated and
print the Fibonacci series.
OUTCOMES:
After this experiment, students will acquire knowledge of decision control structures in python
and its application.
THEORY:
Fibonacci numbers in the following integer sequence, called the Fibonacci sequence:
0,1,1,2,3,5,8,13,21,34,55,89,144…..
The first two numbers in the Fibonacci sequence are 0 and 1 and each subsequent number is
the sum of the previous two. Mathematically Fn = Fn-1 + Fn-2
F2 = F0 + F1 = 0+1=1
F3 = F1 + F2 = 1+1=2
F4 = F2 + F3 = 2+1=3
F5 = F3 + F4 = 2+3=5 likewise
ALGORITHM:
Step 1: start
Step 2: declare f1,f2,f3,n,i
Step3: initialize f1=0,f2=1
Step 4: accept the value of n from user
Step 5: print values of f1 and f2
Step 6: for i=2 to n
Step 7:f3=f2+f1
Step 8: print the value of f3
Step 9: assign f2 to f1 and f3 to f2
Step 10:end for
Step 11: stop
FLOWCHART:
CONCLUSION:
Thus, we have successfully generated Fibonacci series in python using decision control
statements.
Attach Screenshots of program here
Flowchart
EXPERIMENT NO: 3
OUTCOMES:
THEORY:
This assignment will read the number and perform different operations
on that number.
Variable:
In programming, a variable is a container (storage area) to hold data. To indicate the storage
area, each variable should be given a unique name (identifier). Variable names are just the
symbolic representation of a memory location.
For Loop:
Unlike the while loop and do…while loop, the for loop contains the initialization, condition,
and updating statements as part of its syntax. It is mainly used to traverse arrays, vectors, and
other data structures.
Syntax of for Loop
Flowchart:
ALGORITHM:
1. Start
2. Declare an integer variable to give input for square root, square, checking for prime,
factorial, prime factors calculation.
3. Declare an integer variable to store the output value.
4. Perform square root, square operation and store result into another variable.
5. Declare a flag variable to set the initial value=0.
6. If input number is 0 and 1 then flag set to 1 and display it is prime no.
7. If n is divisible by i, then n is not prime.
8. If n is not divisible by i then n is prime.
9. calculate fact=fact * i
10. Use the condition as if (num % i == 0) then display prime no.
11. Display the result.
12. End
TITLE: To accept a student's marks for five subjects, compute his/her result. Student is
passing if he/she scores marks equal to and above 40 in each course. If student scores
aggregate greater than 75%, then the grade is distinguished. If aggregate is 60>= and <75
then the Grade of first division. If aggregate is 50>= and <60 then the grade is second
division. If aggregate is 40>= and <50 then the grade is third division.
OBJECTIVES:
1. To study Decision Control Statements
2. To understand and apply an if-else statement.
OUTCOMES:
After this experiment, students will acquire knowledge of decision control structures
in C and its application.
THEORY:
if (condition) {
// code to be executed if the condition is true
}
if-else Statement:
The if-else statement is a decision-making statement that is used to decide whether the part of
the code will be executed or not based on the specified condition (test expression). If the
given condition is true, then the code inside the if block is executed, otherwise the code inside
the else block is executed.
Syntax of if-else:
if (condition) {
// code executed when the condition is true
}
else {
// code executed when the condition is false
}
if-else-if Ladder in C
The if else if statements are used when the user has to decide among multiple options. The C
if statements are executed from the top down. As soon as one of the conditions controlling
the if is true, the statement associated with that if is executed, and the rest of the C else-if
ladder is bypassed. If none of the conditions is true, then the final else statement will be
executed. if-else-if ladder is similar to the switch statement.
Syntax of if-else-if Ladder
if (condition)
statement;
else if (condition)
statement;
.
.
else
statement;
Flowchart of if-else-if Ladder
Algorithm:
3. Check the condition if marks >75 and marks <60 then it is distinction.
4. Check the condition if marks >60 and marks <50 then it is first class.
5. Check the condition if marks >50 and marks <40 then it is second class.
CONCLUSION:
Thus, we have successfully compute the marks and display its grade using decision
control statement.
Attach Screenshot of program here
Flow Chart
EXPERIMENT NO: 5
Title: To accept two numbers from the user and compute the smallest divisor
and Greatest Common Divisor of these two numbers.
OUTCOMES:
THEORY:
This assignment will read the number and perform different operations on that
number.GCD stands for Greatest Common Divisor and is also known as HCF
(Highest Common Factor). The GCD of two numbers is the largest positive
integer that completely divides both numbers without leaving a remainder.
Variable:
In programming, a variable is a container (storage area) to hold data. To indicate the storage
area, each variable should be given a unique name (identifier). Variable names are just the
symbolic representation of a memory location.
For Loop:
Flowchart:
Algorithm:
CONCLUSION:
Thus, we have successfully calculated GCD and LCM in C using decision control
statements.
Attach Screenshot of program here
Flow Chart
EXPERIMENT NO: 6
OBJECTIVES:
1. To study Decision control statements
2. To understand and apply if-else and for statements.
OUTCOMES:
After this experiment, students will acquire knowledge of decision control structures
in C and its application.
For example, an array with name ‘a’ having maximum 5 integer elements
can be declared as int a[5];
This declaration allocates 5 consecutive memory locations that can store
5 integer values. The elements are referred to using the combination of
array name and index value. The array index is referred to as ‘subscript’.
For example, elements are referred to as a[0], a[1], a[2], …,
a[MAX_SIZE-1]. Following figure shows the scenario of the above
declaration in memory:
Index: 0 1 2 3 4
The number of memory locations required to hold an array depends on its type and size.
For a one dimensional array, its total size is,
Total Size=Size of array*Size of (array data type).
In above declaration, size of array ‘a’ is 5*2=10 bytes.
Array Initialization
ALGORITHM:
1. Declare an Array with size, key and element found, sum, avg variable.
2. Enter the size of array and no of elements in array
3. Enter the key element to be searched.
4. Compare the key element with every element
5. if element matched then display element found and if not then
display element not found.
6. Perform addition of all elements.
7. Perform an average of it.
8. Display sum and average both.
TITLE: Write a C program that accepts a string from the user and performs the
following string operations- i. Calculate length of string ii. String reversal iii.
Equality check of two Strings iii. Check palindrome ii. Check substring
OBJECTIVES:
1. To understand different types of built in functions.
2. To understand different syntax of built in functions..
OUTCOMES:
THEORY:
The C string functions are built-in functions that can be used for various operations and
manipulations on strings. These string functions can be used to perform tasks such as
string copy, concatenation, comparison, length, etc. The <string.h> header file contains
these string functions.
String Functions in C
1.strlen() Function
The strlen() function calculates the length of a given string. It doesn’t count the null character
‘\0’.
Syntax
int strlen(const char *str);
2. strcmp() Function
The strcmp() is a built-in library function in C. This function takes two strings as arguments
and compares these two strings lexicographically.
Syntax
int strcmp(const char *str1, const char *str2);
3 strchr() Function
The strchr() function in C is a predefined function used for string handling. This function is
used to find the first occurrence of a character in a string.
Syntax
char *strchr(const char *str, int c);
4 strrev() Function
It is a built-in function in C and is defined in string.h header file. The strrev() function is used
to reverse the given string.
Syntax:
char *strrev(char *str);
Algorithm:
TITLE: Create Structure EMPLOYEE for storing details (Name, Designation, gender,
Date of Joining and Salary), and store the data and update the data in structure
OBJECTIVES:
1. To understand the concept of structure.
2. To understand how to use a structure..
OUTCOMES:
THEORY:
The structure in C is a user-defined data type that can be used to group items of possibly
different types into a single type. The struct keyword is used to define the structure in
the C programming language. The items in the structure are called its member and they
can be of any valid data type.
C Structure Declaration
We have to declare structure in C before using it in our program. In structure declaration, we
specify its member variables along with their datatype. We can use the struct keyword to
declare the structure in C using the following syntax:
Syntax
struct structure_name {
data_type member_name1;
data_type member_name1;
....
....
};
The above syntax is also called a structure template or structure prototype and no memory is
allocated to the structure in the declaration.
Algorithm:
Assignment No: 2
Q1. What are Operators and Expressions?
Q2 . write the difference between Arithmetic Operators and Relational Operators with program code.
Q3. write difference betweenLogical Operators and Assignment Operators with program code.
Q4. write difference betweenIncrement and Decrement Operators with program code.
Q5. write difference between Conditional Operators, Bitwise Operators with program code.
Assignment No: 3
Q1. How to write a Simple If Statement and If-Else statement? explain with program code.
Q2. How to write a If-Else and Else-If statement? explain with program code.
Q3. write difference between Switch Statement and Goto Statement
Q4. What is a Decision Making and Looping statement? List out with syntax
Q5. Write a Simple program to define While Statement, Do-While, For Statement, Break and Continue, write
separate program code for each.
Assignment No: 4
Q1. What is Arrays: explain with program code.
Q2. Write a simple Program to calculate the result of any five subjects using an array.
Q3. Write any 4 Characteristics of Arrays and Strings
Q4. Explain with Syntax of Declaration and Initialization String Variables, Reading Strings from Terminal,
Writing Strings to Screen, Putting Strings Together, Comparison of Two Strings.
Q5. write difference between One Dimensional Arrays and Two –dimensional Arrays.
Assignment No: 5
Q1. Whats is User Defined Functions: write in brief about Definition of Functions, Return Values and
their Types, Function Calls, Function Declaration,
Q2. Write a short note on Category of Functions:
1. No Arguments and no Return Values
2. Arguments but No Return Values
3 .Arguments with Return values
4. No Arguments but Returns a Value
5.Functions that Return Multiple Values
6.Nesting of Functions
7. Recursion
Q4. What is a Structure? Structure Type Declarations, Structure Declarations, Referencing
Structure Members
Q5. Write a notes on Referencing Whole Structures, Initialization of Structures.
FUNDAMENTALS OF PROGRAMMING LABORATORY (ESC-105-COM)
Sr CO
Name of Experiment/Activity
No Mapped
To accept the number and Compute a) square root of number, b) Square of
number, c) Cube of number d) check for prime, d) factorial of number e) prime
1 CO1
factors.
To accept from user the number of Fibonacci numbers to be generated and print CO2
the Fibonacci series.
2
To accept an object mass in kilograms and velocity in meters per second and
3 display it’s Momentum. Momentum is calculated as e=mc2 where m is the mass CO2
of the object and c is its velocity.
In array do the following: CO4
1. Find given element in array
2. Find Max element
4
3. Find Min element
4. Find frequency of given element in array
5. Find Average of elements in Array.
6. Find Average of elements in Array.
Write a C program that accepts a string from the user and performs the following
8 string operations- i. Calculate length of string ii. String reversal iii. Equality check CO4
of two Strings iii. Check palindrome ii. Check substring.
Create Structure EMPLOYEE for storing details (Name, Designation, gender, Date
9 of Joining and Salary), and store the data and update the data in structure. CO5
Create class STORE to keep track of Products (Product Code, Name and price).
10 Display menu of all products to users. Generate bills as per order. CO4
FUNDAMENTALS OF PROGRAMMING (ESC-102-COM) Practical
Course Outcomes:
After successful completion of the course, the students should be able to: ↓
C05: Improved ability to implement and test solutions for complex engineering
problems using programming.
2 CO2 3 3 3 3
3 CO3 3
4 CO4 2 2 2 2
5 CO5 3 3
Avg. 3.00 3.00 3.00 3.00 3.00 2.00 2.00 3.00 2.00 2.00
CO PO Mapping Justification
Sr. CO CO Statement Level PO Justification
No. After successful
completion of the
course, the students
should be able to: ↓
1 CO1 Learn ability to apply 3 PO1 Requires analyzing engineering problems and
programming applying programming concepts to find solutions. The
concepts to solve ability to identify, formulate, and analyze problems
engineering using programming aligns with this PO, which
Problems. emphasizes problem-solving and analysis.
3 PO2 Proficiency in programming languages allows students
to conduct thorough investigations of engineering
systems. This involves applying various programming
tools to explore and analyze system requirements and
solutions.
2 CO2 Understand 3 PO4 Proficiency in programming languages allows students
Proficiency in using to conduct thorough investigations of engineering
programming systems. This involves applying various programming
language to analyze tools to explore and analyze system requirements and
and design solutions.
engineering systems. 3 PO5 Using programming languages effectively for analysis
and design demonstrates the use of modern
engineering tools and techniques. This PO highlights
the ability to employ up-to-date tools to solve
engineering problems.
3 CO3 Enhanced problem- 3 PO3 Developing problem-solving skills through coding and
solving skills through algorithms involves designing and synthesizing
coding and algorithm solutions. This CO aligns with the ability to create
development. effective solutions and systems, which is central to the
design and development aspect of this PO.
4 CO4 Understanding of the 2 PO6 Understanding computational thinking emphasizes its
importance of the role in enhancing engineering practices and its impact
computational on societal issues. This PO focuses on how engineering
thinking in solutions affect society and how computational
engineering practice. thinking contributes to these solutions.
2 PO7 Computational thinking can lead to more efficient and
sustainable engineering solutions. This CO reflects the
understanding of how computational methods
contribute to sustainability and environmental
considerations.
2 PO9 Computational thinking aids both individual and team
work in engineering by providing structured problem-
solving approaches. Understanding how these
methods improve collaboration and individual tasks
aligns with this PO.
2 PO10 Computational thinking helps in organizing and
presenting solutions clearly. Understanding the role of
computational thinking in effective communication
supports this PO by emphasizing clear articulation of
solutions.
5 CO5 Improved ability to 3 PO8 Implementing and testing solutions requires
implement and test adherence to ethical standards in software
solutions for complex development and engineering. This CO involves
engineering problems applying ethical considerations in the development
using programming. and testing phases.