0% found this document useful (0 votes)
25 views7 pages

Lab_PSUC_List of Experiments (1)

The document outlines the curriculum for the CS 1031 Problem-Solving Using Computers Lab at the Faculty of Engineering for the Jan-May 2024 session. It includes weekly topics, session outcomes, and detailed lab experiments focusing on algorithms, control structures, arrays, strings, functions, pointers, and structures in C programming. Each lab session consists of specific programming tasks designed to reinforce the concepts taught in the course.

Uploaded by

nevaidhyasingh
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)
25 views7 pages

Lab_PSUC_List of Experiments (1)

The document outlines the curriculum for the CS 1031 Problem-Solving Using Computers Lab at the Faculty of Engineering for the Jan-May 2024 session. It includes weekly topics, session outcomes, and detailed lab experiments focusing on algorithms, control structures, arrays, strings, functions, pointers, and structures in C programming. Each lab session consists of specific programming tasks designed to reinforce the concepts taught in the course.

Uploaded by

nevaidhyasingh
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/ 7

Faculty of Engineering (FOE)

Problem-Solving Using Computers Lab


|CS 1031 | 1 Credit | 0 0 2 1
Session: Jan-May 2024

Lab Experiments

Week Topics Session Outcome

1 Algorithms and Flow Charts Describe the flowcharts and design of an algorithm

Use Unix commands to manage files and develop


2 Working with Linux Commands
programs,including multi-module programs

3 Formula-based CPrograms Understand the fundamentals of C programming.

Choose the decision-making statements to solve the


4 Control Structures: if statement
problem.

Choose the decision-making statements to solve the


5 Control Structures: Switch
problem.

6 Control Structures: Loops Choose the loop statements to solve theproblem

7 Control Structures: Nested Loops Choose the loop statements to solve the problem

8 1-D Array Implement different Operations on 1-D arrays.

9 2-D Arrays Implement different Operations on 2-D arrays

10 Strings Implementation of different Operations on strings

11 Functions Use functions to solve the given Problem


Understand and apply the concept of pointers in
12 Pointers
programming

Understand and apply the concept of Structure in


13 Structures
programming
Lab 1. Algorithms and Flowcharts

1. To multiply to numbers.
2. To divide two numbers.
3. To check whether the given number is even or odd.
4. To swap two numbers.
5. To check whether the given number is lesser than 10 or not.
6. To convert Fahrenheit to Celsius.
7. To check the greater number in the given two numbers.
8. To calculate simple interest.
9. To check whether the given number is prime or not.
10. To calculate area of the given rectangle.

Lab 2. Working with Linux Commands

22 clear Clear terminal

23 ps Display the processes in terminal

24 man Access manual for all Linux commands

25 grep Search for a specific string in an output

26 echo Display active processes on the terminal


27 sort sort the file content

28 cal View Calendar in terminal

29 df Check the details of the file system

30 wc Check the lines, word count, and characters in a file


using different options

Lab 3. Formula based C Programs


1. Write a program to convert the time in seconds to hours, minutes, and seconds. (1 hr =
3600 sec).
2. Write a program to find the sum of the digits of a four-digit number (ex.
1234 sum=10)(without using a loop).
3. Write a program to convert the temperature given in Fahrenheit to
Centigrade andCentigrade to Fahrenheit. Hint: C=5/9(F-32)).
4. Write a program for converting distance in mm to cm, inch, feet
(1 cm =10mm,1inch=2.5cm, 1 feet =12 inches).
5. Write a program to find out the distance between two points e.g. (x1, y1) and (x2, y2).
Hint: Distance=√(x2-x1)2+ (y2-y1)2
6. Write a program to evaluate the area of the circle Area = Pi * R2
7. Write a program to interchange the values of two variables using a third variable.
8. Write a program to interchange the values of two variables without using a third variable.

Lab 4. Control Structures: If statement


1. Write a program to check whether the given number is odd or even.
2. Write a program to check whether a given year is a leap year or not.
3. Write a program to find the roots of a quadratic equation.
a. Hint: root = -b +/- sqrt(b2-4ac)/2a
4. Write a program to find the total no. of days for a given number of
months countingfrom January month.
a. Example: m=3, days=31+ (28 0r 29) + 31.
5. Write a program to take two numbers as an input and find whether
one number is amultiple of the other or not.
6. Write a program that returns a letter grade based on a quiz score. The
input will be theinteger score from a ten-point quiz.
a. The letter grades are assigned by:
b. 9-10“A”7-8“B”5-6“C”3-4“D”<3“F”
7. Write a program that takes three sides of a triangle input and calculates its
area, if theseconditions are satisfied a+b>c, b+c>a, a+c>b, calculate
area=(a+b+c)/2
8. Write a program to check whether the given character is a vowel, consonant, or digit.
Lab 5. Control Structures: Switch
1. Write a program to program to calculate an area of a circle, a rectangle, or a triangle
depending on the user’s choice.
2. Write a program to remove all the break statements from Ex-1 (with switch-case construct)
and try to execute the program with a few inputs. Observe the difference.
3. Write a program to program to input the number of week’s days (1-7) and translate to its
equivalent name of the day of the week (e.g., 1 to Sunday, 2 to Monday)
4. Write a program to design a calculator that performs addition, subtraction, minus, and
division operation. This program inputs two operands and an operator and then displays the
calculated results.
5. Write a program to calculate a bill for internet browsing. The conditions are given below:
Minimum Rs. 200 for up to 100 calls.
Plus, Rs. 0.60 per call for the next 50 calls. Plus, Rs. 0.50 per call for the next 50 calls.
Plus, Rs. 0.40 per call for any call beyond 200 calls
6. Write a program to calculate an amount of a telephone bill for the following criteria. (Without
Loop)
Calls charge per call (Rs.)
1-150 0
151-250 .9
251-400 1.2
401 onwards 1.5

7. Write a program to calculate the amount of an electricity bill for the following criteria.
(Without Loop)
Units charge per unit (Rs.)
First, 1-100 up to 0
Next, 101-200 up to 1.5
Next, 201-400 up to 2.5
401 onwards 3.5

8. Write a program to calculate the discount in rupees for the following criterion. (Without Loop)
Cost price discount
>=800 25%
500-800 20%
<500 no discount (0%)

Lab 6. Control Structures: Loops

1. Write a program to take N as input and print the odd numbers in descending order.
2. Write a program to print the Fibonacci number.
Hint: (Fibonacci series is 0, 1, 1, 2, 3, 5, 8,)
3. Write a program to find whether the given number is prime or not.
4. Write a program to convert the decimal number into
binary to decimal. Ex: 1101 = 1*2 3 + 1 * 2 2 + 0 *
2 1+ 1* 2 0 =13
5. Write a program to reverse a given number
Ex: 1234 reverse=4*10 3 +3 * 10 2 + 2 * 10 1 + 1 * 10 0 =4321
6. Write a program to find the sum of n terms of the sin series sin(x) = x - x3 + x5 – x7
7. Write a program to check whether a given integer no. is palindrome or not.
8. Write a program to check whether the given number is Armstrong or not. An
Armstrong number of three digits is an integer such that the sum of the cubes of
its digits is equal to the number itself. For example, 371 is an Armstrong
number since 33 + 73 + 13 = 371.

Lab 7. Control Structures: Nested Loops


1. Write a program to print different patterns using nestedloops.
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

1
2 2
3 3 3
4 4 4 4
5 5 5 5 5 5

5 5 5 5 5
4 4 4 4
3 3 3
2 2
1

1
2 4
3 5 7
6 8 10 12
9 11 13 15 17

5. Write a program to generate the multiplication table for n numbers up to k terms (nested
loops).
6. Write a program to print the Fibonacci numbers that fall in the given range.
7. Write a program to print the Nth the prime number.
8. Write a program to print the Nth the Armstrong number.

Lab 8. 1-D Array


1. Write a program to find the largest and smallest element in an array.
2. Write a program to find the sum of odd index numbers in an array.
3. Write a program to print the subarray that lies between the two indexes.
4. Write a program to find the number of positive numbers, negative numbers, oddnumbers,
even numbers, and the number of 0 of an array.
5. Write a program to reverse an array with an auxiliary array.
6. Write a program to check whether an array is sorted or not.
7. Write a program to arrange the elements of an array in ascending order by a simple sorting
method. (Selection sort/bubble sort)
8. Write a program to take an array of 10 elements. Split it into the middle and store the elements
in two different arrays. E.g.- Initial array:

58 24 13 15 63 9 8 81 1 78

After splitting:

58 24 13 15 63

9 8 81 1 78

Lab 9. 2-D Arrays


1. Write a program to take 3 student marks in 5 subjects. Print the total marks of eachstudent
and the average marks of each subject.
2. Write a program for searching for an element in the matrix and counting the number of
occurrences of that element.
3. Write a program to multiply two matrices.
4. Write a program to check if the given matrix is a magic square or not.
5. Write a program to find whether a given matrix is symmetric or not.
Hint: A = AT
6. Write a program to find the trace and norm of a given square matrix.
Hint: Trace = sum of principal diagonal elements
Norm = sort (sum of squares of the individual elements of an array)

Lab 10. Strings

1. Write a program to change all lower-case letters into upper case in a sentence.
2. Write a program to find the last occurrence of a particular character.
3. Write a program to concatenate/length/copy two strings using the library function.
4. Write a program to count the number of words in a sentence.
5. Write a program to reverse a string.
6. Write a program to find the string length of a string without using the predefined function.
7. Write a program to find the substring of a given string.
8. Write a program to check if the given string is a palindrome or not.

Lab 11. Functions


1. Write a program to find the factorial of a number using a function. (Ex: 5! =5*4*3*2*1. Use
a function Fact to evaluate factorial & print the result).
2. Write a program to find the maximum of a given set of numbers using functions. (Use a
function Max and return the result to the main function)
3. Write a program to find the GCD of two numbers recursively. (Ex: GCD of 9, 24 is 3)
4. Write a program to check whether the given number is prime or not. Using this function
generates first n prime numbers using the above function.
5. Write a function to generate the nth Fibonacci term using recursion. Print first N Fibonacci
terms using this function. Hint: (Fibonacci series is 0, 1, 1, 2, 3, 5, 8,)
6. Write a program to check if the given string is a palindrome or not, using the stringhandling
function.
7. Write a function Sort for sorting a list of names which will use a function compare to
compare two names. (Selection /bubble Sort may be used).

Lab 12. Pointers


1. Write a program to access two integers using pointers and add them.
2. Write a program to find out the greatest and the smallest among the three numbers usingpointers.
3. Write a program to determine the length of a character string using a pointer.
4. Write a program to compute the sum of all elements stored in an array using a pointer.
5. Write a program to determine whether a substring (string 1) is in the main string or not.If present,
return the pointer of the first occurrence.

Lab 13. Structures

1. Write a program to define a structure personal that would contain the person’s name, date of
joining, and salary. Using this structure write a program to read this information for one person
from the keyboard and print the same on the screen.
2. Write a program to create an array of student structures to store the roll no., name, and marks in
3 subjects. Input the details of N students into the array and display roll no., name, and total
marks of each student in decreasing order of total marks.
3. Write a program to create an array of employee structures to store emp-no, name, basic salary,
and HRA. Input the details of N employees and display emp-no, name, basic, HRA, and net
salary. Display the details of all employees whose net salary is more than the average net salary
of all employees.
4. Write a program to create a structure named Date having day, month, and year as its elements.
Store the current date in the structure. Now add 45 days to the current date and display the final
date.

Lab 14. End-term Exam

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy