[go: up one dir, main page]

0% found this document useful (0 votes)
36 views19 pages

FPL Manual

Uploaded by

Shweta borse
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)
36 views19 pages

FPL Manual

Uploaded by

Shweta borse
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/ 19

Gokhale Education Society’s

R. H. Sapat College of Engineering,


Management Studies & Research, Nasik – 422 005.

An ISO 9001:2015 Certified Institute | Accredited by NAAC with B++

First Year Engineering, FE (2024)

R. H. Sapat College of Engineering,


Management Studies & Research, Nasik – 422 005.

AS PER SAVITRIBAI PHULE PUNE UNIVERSITY (SPPU) SYLLABUS (2024 PATTERN


R. H. Sapat College of Engineering,
Management Studies & Research, Nasik – 422 005.

Department of Engineering Sciences (FE)

Fundamentals of Programming Languages


(F.E. 2024 Course)

LABORATORY MANUAL

Prepared By Approved By
Dr. D. V. Patil
Subject Teacher
(H.O.D)
Course Objective:

1. To understand the fundamental Concepts of C Programming.


2. To acquire knowledge and Compare usage of Operators and Expressions in C Programming.
3. To apply Control Flow structures in C Programming for Problem solving.
4. To design a solution using Arrays, Character and String Arrays in C programming.
5. To design and develop solutions for simple computational problems using User Defined Functions in C
Programming.
6. Justify the use of structures in Problem solving using the C programming language.

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

List of Experiment (Any 6 to 8 laboratory assignments only)

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 it’s 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
R. H. Sapat College of Engineering,
Management Studies & Research, Nasik – 422 005.

Department of Engineering Sciences (FE)

INDEX
Exp. Title of Experiment DoP DoA Remark/ Sign
No. Marks
1 To accept the number and Compute 1.square root of number,
2.Square of number, 3.Check for prime 4.Factorial of number.
2 To accept from the user the number of Fibonacci numbers to
be generated and print the Fibonacci series.
3 Write a C program for employee salary calculation given,
Basic, H.R.A. 20 % of Basic and D.A. 150 % of Basic
4 To accept a student's marks for five subjects, compute
his/her result as D,1st class,2nd class, Pass & Fail.
5 In the array do the following: 1. Find given element 2. Find
Max element 4. Find frequency 5. Find Average of
elementsA.
6 To accept a string performs the following string operations-
i. Calculate length ii. String reversal iii. Equality
7 Create Structure EMPLOYEE for storing details (Name,
Designation, gender, Date of Joining and Salary) display
results.

CERTIFICATE

This is to certify that Mr. / Ms.

Class Roll No. University Exam Seat No. has

Completed all the practical work satisfactorily in the subject of Fundamentals of

Programming Languages as prescribed by the Savitribai Phule Pune University (SPPU).

Date:
Academic Year: 2024-25

Sub. In Charge Head of Department Principal


EXPERIMENT NO: 1

TITLE To accept the number and Compute a) square root of number, b) Square
of number, c) Cube of number d) check for prime, e) factorial of number f) prime
factors.

OBJECTIVES: 1. To understand different types of operators.


2. To understand basic logic building and syntax.

OUTCOMES:

After this experiment, students will acquire knowledge of operators


in C language and how to use them.

AIM: (A) STUDY OF IF-ELSE STATEMENTS IN C.


(B) DECLARATION OF VARIABLES IN C.
(C) ACCEPTING AND DISPLAYING INPUT VALUES.
(D) CALCULATE DIFFERENT OPERATION ON NUMBER.

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:

The for loop in C Language provides a functionality/feature to repeat a set of statements a


defined number of times. The for loop is in itself a form of an entry-controlled 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

for(initialization; check/test expression; updation)


{
// body consisting of multiple statements
}

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

CONCLUSION: Thus, we have successfully calculated the gross salary of an employee in


C using decision control statement
EXPERIMENT NO: 2

TITLE: To accept from the user the number of Fibonacci numbers to be generated and
print the Fibonacci series.

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
python and its application.

AIM: (A) STUDY OF IF-ELSE STATEMENTS IN C

(B) DECLARATION OF VARIABLES IN C

(C) ACCEPTING AND DISPLAYING INPUT VALUES

(D)UNDERSTAND AND CALCULATE FIBONACCI SERIES.

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

With first two numbers

F0 =0, F1 =1 Following numbers can be calculated


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 C using decision control


statements.
EXPERIMENT NO: 3

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.

AIM: (A) STUDY OF IF-ELSE AND WHILE STATEMENTS IN C


(B)DECLARATION OF VARIABLES IN C
(C)ACCEPTING AND DISPLAYING
(D) CALCULATE SALARY OF EMPLOYEE

THEORY:

This assignment will read Basic Salary of an employee, calculate other part of the
salary on percent basic and finally print the Salary of the employee. Here, we are reading
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.

For example: int age=24;

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:

Thus, we have successfully calculated the gross salary of an employee in C using


decision control statements.
EXPERIMENT NO: 4

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:

The if-else statement in C is a flow control statement used for decision-making in


the C program. It is one of the core concepts of C programming. It is an extension of
the if in C that includes an else block along with the already existing if block.
if Statement:

The if statement in C is used to execute a block of code based on a specified condition.


The syntax of the if statement in C is:

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:

1. Declare num variable.

2. Enter the marks from the user .

3. Check the condition if marks >75 and marks <60 then it is a 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.

6. If marks <40 then it fails.

CONCLUSION:
Thus, we have successfully computed the marks and displayed its grade using a
decision control statement in C.
EXPERIMENT NO:5

TITLE: In 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.

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.

AIM: (A) STUDY OF IF-ELSE AND FOR STATEMENTS IN C.


(B) DECLARATION OF VARIABLES IN C.
(C) ACCEPTING AND DISPLAYING INPUT VALUES.
(D) CALCULATE MINIMUM, MAXIMUM, AVG. AND
FREQUENCY FROM ARRAY.
THEORY:

An array in C is a fixed-size collection of similar data items stored in contiguous


memory locations. It can be used to store the collection of primitive data types such
as int, char, float, etc., and also derived and user-defined data types such as pointers,
structures, etc.

Syntax of Array Declaration:

data_type array_name [size1] [size2]...[sizeN];

Where N is the number of dimensions.


The ‘data type’ in the declaration refers to the type of each element in the
array. ‘array_name’ refers to the name by which the memory locations will
be identified. ‘MAX_SIZE’ indicates the maximum number of elements that
can be stored in the array.

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 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:

Address: 3001 3003 3005 3007 3009

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

An integer array can be initialized during its


declaration. For example, int
marks[4]={67,80,55,79};
char grades[4]={‘A’, ‘B’, ‘C’, ‘D’};
The elements will be stored in the memory as shown in the figure below

Address: 5010 5012 5013 5015


67 80 55 79
Index: 0 1 2 3

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.

CONCLUSION:
Thus, we have successfully determined about array in C using decision
control statements.
EXPERIMENT 6

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:

After this experiment, students will acquire knowledge of built in functions in C


language and how to use them.

AIM: (A) STUDY OF STRING IN C.


(B) DECLARATION OF STRING VARIABLES IN C.
(C) ACCEPTING AND DISPLAYING STRING INPUT.
(D) PERFORM DIFFERENT OPERATION ON STRING.

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:

1. Declare string variables with size.


2. Enter the string.
3. Calculate length, reverse,equal,palindrome and substring of the string using built in
function.
4. Compute the result.
5. Display the result.

CONCLUSION:

Thus, we have successfully performed operations on string.


EXPERIMENT 7

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:

After this experiment, students will acquire knowledge of structures in C language


and how to use them.

AIM: (A) STUDY OF STRUCTURES IN C.


(B) DECLARATION OF STRUCTURE VARIABLES IN C.
(C) ACCEPTING AND DISPLAYING INPUT IN STRUCTURE
VARIABLE.
(D) PERFORM DIFFERENT OPERATION ON STRUCTURE.

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:

1.Declare structure variable with all members.


2.Create object of structure.
3.Enter data using structure object and structure member.
4.Display data using structure object and structure member.

CONCLUSION:

Thus, we have successfully completed structure operations.

You might also like