cs8261 Lab Manual
cs8261 Lab Manual
cs8261 Lab Manual
II SEMESTER - R 2017
LABORATORY MANUAL
Name : _______________________________________
Register No : _______________________________________
Section : _______________________________________
VISION
MISSION
To provide competent technical manpower capable of meeting requirements
of the industry
To contribute to the promotion of Academic excellence in pursuit of
Technical Education at different levels
To train the students to sell his brawn and brain to the highest bidder but to
never put a price tag on heart and soul
1. FUNDAMENTALS
To impart students with fundamental knowledge in Mathematics, Science
and fundamentals of engineering that will mould them to be successful
professionals
2. CORE COMPETENCE
To provide students with sound knowledge in engineering and
experimental skills to identify complex software problems in industry and to
develop practical solutions for them
3. BREADTH
To provide relevant training and experience to bridge the gap between
theory and practice this enables them to find solutions for real time problems in
industry and organization, and to design products requiring interdisciplinary skills
4. PROFESSIONALISM SKILLS
To bestow students with adequate training and provide opportunities to
work as team that will build up their communication skills, individual leadership
and supportive qualities, and to enable them to adapt and work in ever changing
technologies
5. LIFELONG LEARNING
COURSE OBJECTIVES
LIST OF EXPERIMENTS:
Mini project
18. Create a ―Railway reservation system with the following modules
Booking
Availability checking
Cancellation
Prepare chart
COURSE OUTCOMES
Sl. Page
Name of the Experiment
No. No.
Mini project
1. Create a ―Railway reservation system with the
following modules
Booking
18. 43
Availability checking
Cancellation
Prepare chart
Aim:
To write a C program that uses I/O statements and expressions.
Algorithm:
Program:
Result:
Thus a C program that uses I/O statements and expressions is executed
successfully and the output is verified.
Aim:
To write a C program using decision making constructs.
Algorithm:
Program:
Result:
Thus a C program that uses decision making constructs is executed
successfully and the output is verified.
Aim:
To write a C program to check whether the given year is a leap year or not
using if statement.
Algorithm:
1) Start
2) Read the value of year
3) If year divisible by 400 then print "Leap year"
3.1) Else if year divisible by 4 and not divisible by 100 then print "Leap
year"
3.2) Else print "Not a leap year"
4) Stop
Program:
Result:
Thus the C program to find the given year is a leap year or not is executed
successfully and the output is verified.
Aim:
To write a C program to design a calculator to perform the operations,
namely, addition, subtraction, multiplication, division and square of a number.
Algorithm:
1) Start
2) Display calculator menu options
3) Read the operator symbol and operands n1, n2
4) If operator = + then calculate result = n1 + n2
4.1) Else if operator = – then calculate result = n1 – n2
4.2) Else if operator = * then calculate result = n1 * n2
4.3) Else if operator = / then calculate result = n1 / n2
4.4) Else if operator = % then calculate result = n1 % n2
4.2) Else print "Invalid operator" and go to step 6
5) Print result
6) Stop
Program:
Simple Calculator
1. Summation
2.Difference
3.Product
4. Quotient
5. Remainder
Enter the case : 1
Enter operand1 and operand2 : 2 4
2+4=6
Result:
Thus the C program for designing a calculator to perform the operations,
namely, addition, subtraction, multiplication, division and square of a number is
executed successfully and the output is verified.
Aim:
To write a C program to find if a number is Armstrong or not.
Algorithm:
1. Start
2. Read number
3. Set sum=0 and duplicate=number
4. Reminder=number%10
5. Sum=sum+(reminder*reminder*reminder)
6. Number=number/10
7. Repeat steps 4 to 6 until number > 0
8. If sum = duplicate
9. Display number is armstrong
10. Else
11. Display number is not armstrong
12. Stop
Program:
Result:
Thus the C program for finding an Armstrong number is executed
successfully and the output is verified.
Aim:
To write a C program to find the sum of weights based on the given
conditions.
Given a set of numbers like <10, 36, 54, 89, 12, 27>, find sum of weights based
on the following conditions.
5 if it is a perfect cube.
4 if it is a multiple of 4 and divisible by 6.
3 if it is a prime number.
Sort the numbers based on the weight in the increasing order as shown below
<10,its weight>,<36,its weight><89,its weight>
Algorithm:
1. Start
2. create dynamic array for size n
3. set all weightage to zero
4. check and find the weightage
5. sort number in ascending
6. print the weightage
7. stop
Program:
5
10
36
54
89
12
<10,2><12,6><36,11><54,2><89,2>
Result:
Thus the C program for finding the sum of weights is executed
successfully and the output is verified.
Aim:
To write a C program to Populate an array with height of persons and find
how many persons are above the average height.
Algorithm:
1. Start
2. Set avgheight=0
3. Declare array ‘a’ with ten values
4. For i =0 till ten, perform the following
i. if a[i] is between 150.0 and 165.0 , then print the height
ii. Increment avgheight
5. Print avgheight
6. Stop
Program:
Result:
Aim:
To write a C program to Populate a two dimensional array with height and
weight of persons and compute the Body Mass Index of the individuals.
Algorithm:
1. Start
2. Get the input height from the user
3. Get the input weight from the user
4. Calculate the BMI with formula w/(h*h)
5. Print the result
6. Stop
Program:
Result:
Thus the C program to Populate a two dimensional array with height and weight
of persons and compute the Body Mass Index of the individuals is executed
successfully and the output is verified.
Aim:
To write a C program to reverse a string without changing the position of
special characters. (Given a string ―a$bcd./fg‖ find its reverse without changing
the position of special characters. )
Algorithm:
1. Start
2. Let input string be 'str[]' and length of string be 'n'
3. l = 0, r = n-1
4. While l is smaller than r, do following
a) If str[l] is not an alphabetic character, do l++
b) Else If str[r] is not an alphabetic character, do r--
c) Else swap str[l] and str[r]
5. Stop
Program:
Result:
Thus the C program to reverse a string without changing the position of
special characters is executed successfully and the output is verified.
Aim:
To write a C program to Convert the given decimal number into binary,
octal and hexadecimal numbers using user defined functions.
Algorithm:
1. Start
2. Take a decimal number as input.
3. Divide the input number by 2,8,16 and obtain its remainder and quotient.
Store the remainder in the array.
4. Repeat the step 2 with the quotient obtained. Do this until the quotient
becomes zero.
5. Print the array in the reverse order to get the output.
6. stop
Program:
Result:
Thus the C program to Convert the given decimal number into binary,
octal and hexadecimal numbers using user defined functions is executed
successfully and the output is verified.
Aim:
To write a C program to perform the following from a given paragraph
using built-in functions,
a. Find the total number of words.
b. Capitalize the first word of each sentence.
c. Replace a given word with another word.
Algorithm:
1. Start
2. Take a string as input.
3. Using for loop search for a empty space in between the words in the
string.
4. Consecutively increment a variable. This variable gives the count of
number of words
5. Check first character is lowercase alphabet if then capitalize ,Continue
the loop ,all the other should be in lowercase.
6. to traverse the original string and count the number of times old word
occurs in the string.
7. Now make a new string of sufficient size so that new word can be
replaced.
8. Now copy original string to new string with replacement of word.
Program:
Result:
Thus the C program for built-in functions is executed successfully and the
output is verified.
Aim:
To write a C program to solve tower of Hanoi using recursion.
Algorithm:
1. Start
2. Read the number of disks
3. Move n-1 disks from source to aux
4. Move nth disk from source to dest
5. Move n-1 disks from aux to dest
6. Stop
Program:
Result:
Thus the C program to solve tower of Hanoi using recursion is executed
successfully and the output is verified.
Aim:
To write a C program to sort the list of numbers using pass by reference.
Algorithm:
1. Start
2. Starting at array index 0, search the entire array to find the smallest value
3. Swap the smallest value found in the array with the value at index 0
4. Repeat steps 1 & 2 starting from the next index
5. Stop
Program:
Result:
Thus the C program to sort the list of numbers using pass by reference is
executed successfully and the output is verified.
Aim:
To write a C program to generate salary slip of employees using
structures and pointers.
Algorithm:
1. Start
2. Structure to store employee salary details
3. Prints payslip for the requested employee
4. Get the number of employees from the user
5. Dynamically allocate memory to store employee salary details
6. Get the employee salary details from the customer
7. Gross and net salary calculation
8. Printing payslip for the given employee id
Program:
Result:
Thus the C program to generate salary slip of employees using structures
and pointers is executed successfully and the output is verified.
Aim:
To write a C program to Compute internal marks of students for five
different subjects using structures and functions.
Algorithm:
1. Start
2. structure, student is created.
3. This structure has three members: name (string), roll (integer) and marks
(float).
4. A structure variable s is created to store information and display the
internal marks on the screen.
5. Stop
Program:
Output
Name: Kevin Amla
Roll: 149
Internal mark for S1:15.6
Internal mark for S2:15
Internal mark for S3:15.2
Internal mark for S4:15.2
Internal mark for S5:18
Result:
Thus the C program to Compute internal marks of students for five
different subjects using structures and functions is executed successfully and the
output is verified.
Aim:
To write a C program to Insert, update, delete and append telephone
details of an individual or a company into a telephone directory using random
access file.
Algorithm:
1. Start
2. Create a function to add data to a file
3. Create a function to update data
4. Create a function to delete the data
5. Create a function to alter the data
6. stop
Program:
Result:
Thus the C program to Insert, update, delete and append telephone
details of an individual or a company into a telephone directory using random
access file is executed successfully and the output is verified.
Aim:
To write a C program to Count the number of account holders whose
balance is less than the minimum balance using sequential access file.
Algorithm:
1. Start
2. The data to be stored is Account number, Name, Balance in account.
3. Assume maximum of 05 customers in the bank.
4. Create a function to read all customers details and call it in main.
5. Program must print the Account number and name and balance of each
customer.
6. Stop
Program:
Result:
Thus the C program to Count the number of account holders whose
balance is less than the minimum balance using sequential access file is
executed successfully and the output is verified.
Aim:
To write a C program Create a Railway reservation system with the
following modules Booking, Availability checking, Cancellation, Prepare chart.
Algorithm:
1. Start
2. The data to be stored is train no ,train availability status , cancellation
details , booking details and preparation chart.
3. Create a function to read all train details and call it in main.
4. Program must print the train no and booking status of each customer.
5. Stop
Program:
Result:
Thus the C program to Count the number of account holders whose
balance is less than the minimum balance using sequential access file is
executed successfully and the output is verified.