You are on page 1of 2

SCHOOL OF COMPUTER SCIENCE AND ENGINEERING

Lab exercise - 1

Date: 18.07.2020 Time: 2:00-4:50PM


Programme : B.Tech (CSE) Semester : FALL 20-21
Course : Data Structures and Algorithm Code : CSE2003
Faculty : Dr. V. Viswanathan and Dr. Sandeep Kumar Slot : L67+L68+L69
Satapathy

Instructions:
 Save file name as regno_Q1.c, regno_Q2.c and so on. For example - 19BCE1021_Q1.c
 Make a zip file for C files for all seven questions and also the screenshots of your output.
 Upload zip file in Moodle.
 Use C to implement the following with functions

1. Write a program to enter a hexadecimal number. Calculate and display the decimal equivalent of this
number.
(Note: Use a separate function for logic of conversion and return the result.)

2. Write a program to print Fibonacci series up-to n terms using tree recursive function call.

3. Write a program to take an input from the user and then check whether it is a number or
character. If it is a character determine whether it is in upper case or lower case.
(Note: Use the pointers)

4. Write a program to interchange the largest and smallest number in an array of n elements.
(Note: Use a different function for swapping using call by address)
5. Write a function "replace" which takes a pointer to a string as a parameter, which
replaces all spaces in that string by minus signs, and delivers the number of spaces
it replaced.
Thus
char *str = "The cat sat";
n = replace (str);
should set str to "The-cat-sat" and n to 2.
6. Write a program to read two integers with the following significance.
The first integer value represents a time of day on a 24-hour clock, so that 1245
represents quarter to one mid-day, that is 12:45.
The second integer represents a time duration in a similar way, so that 345
represents three hours and 45 minutes.
This duration is to be added to the first time, and the result printed out in the same
notation, in this case 1630 which is the time 3 hours and 45 minutes after 12:45.
Typical output might be Start time is 1415. Duration is 50. End time is 1505.
There are a few extra cases for spotting.
Start time is 2300. Duration is 200. End time is 100

7. Use a single-subscripted array to solve the following problem: A company pays its salespeople
on a commission basis. The salespeople receive $200 per week, plus 9% of their gross sales for
that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus
9% of $5000, or a total of $650. Write a program (using an array of counters) that determines
how many of the salespeople earned salaries in each of the following ranges (assume that each
salesperson’s salary is truncated to an integer amount):
a) $200–$299
b) $300–$399
c) $400–$499
d) $500–$599
e) $600–$699
f) $700–$799
g) $800–$899
h) $900–$999
i) $1000 and over

You might also like