0% found this document useful (0 votes)
107 views6 pages

PCS251

The document outlines the syllabus for the Computer Lab II course in the Computer Science and Engineering department for Semester II, detailing the subject code, contact hours, examination duration, and course outcomes. It includes a comprehensive list of programming tasks to be completed each week, focusing on C programming concepts such as multi-dimensional arrays, strings, pointers, structures, unions, and file handling, as well as Python programming tasks. The course aims to equip students with practical skills in programming and problem-solving using both C and Python.

Uploaded by

khushirk80
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)
107 views6 pages

PCS251

The document outlines the syllabus for the Computer Lab II course in the Computer Science and Engineering department for Semester II, detailing the subject code, contact hours, examination duration, and course outcomes. It includes a comprehensive list of programming tasks to be completed each week, focusing on C programming concepts such as multi-dimensional arrays, strings, pointers, structures, unions, and file handling, as well as Python programming tasks. The course aims to equip students with practical skills in programming and problem-solving using both C and Python.

Uploaded by

khushirk80
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/ 6

SEMESTER II

Name of Department: - Computer Science and Engineering


Computer Lab II
1. Subject Code: PCS251 Course Title:

2. Contact Hours: L: 0 T: 0 P: 4

3. Examination Duration (Hrs): Theory 0 Practical 3


4. Relative Weight: CIE 25 MSE 25 SEE 50
5. Credits: 1

6. Semester: 2

7. Category of Course: DSC

8. Pre-requisite: Basics of C Programming

9. Course After completion of the course the students will be able to:
Outcome:
CO1: Understand and apply concepts of multi-dimensional arrays and
strings for providing solutions to homogenous collection of data.
CO2: Understand and apply the concept of pointers involving operations
on strings, overcome the limitations of arrays and handle
heterogeneous collection of datatypes using structures & union.
CO3: Apply concepts of file handling to implement data storage,
manipulation and searching operations.
CO4: Understand and implement the working of user defined functions
to provide solutions to basic problems, strings, and file manipulation
using python scripts.
10. Details of the Course:

Sl. List of problems for which student should develop program and execute Contact
No. in the Laboratory Hours
Week 1: (2D Array)
• Develop a C program to test whether a given matrix of order M × N is an upper
triangular matrix or not. An upper triangular matrix is the one in which all the
elements below its principal diagonal are zero.
1. • Write a C program to read two square matrices of non-zero elements of order M
X M and then subtract the elements of the second matrix from the first matrix.
Then display the resultant matrix to the console.
• Develop a C program to read a square matrix M x M & then find the sum of the
elements around the peripheral. Display their final sum to the console.
Week 2: (2D Array)
• Develop a C program to accept the names in a 2-D array and then search a name
entered by the user. Display an appropriate message to the output screen if
found.
• Develop a C program to read two square binary matrices of order N x N from the
2. user and perform the XOR on the elements of the matrices and print the resultant
matrix to the output screen.
• Design a UDF that returns the by swapping all the elements about the principal
diagonal of a matrix. Develop a C program to implement the function by accepting
the rows and columns in the main program. Display the swapped matrix in the
calling program.

Week 3: (Character Arrays and Strings)


• Write a C program to read a sentence from the user and replace all the
occurrences of vowels with a X character. Display the modified string to the
console.
• Develop a C program to concatenate two strings and display the concatenated
string to the output screen without using the inbuilt function.
Sample Input:
Input string1: Good (Space is typed after Good)
Input string2: Afternoon
3. Output: Good Afternoon
• Write a C program that accepts a main string along with a starting position and
ending position of a substring to be extracted from the user in the main program.
Print the extracted string in the calling program.
Sample Input:
Main String: A good education transforms an individual into a good citizen
Starting Position: 18
Ending Position: 27
Output:
Sub-string extracted from the main string: transforms
4. Week 4: (Character Arrays and Strings)
• Develop a C program to compare two strings using a UDF and return 1 if the
strings are equal and 0 otherwise without using the built-in function strcmp().
Display an appropriate message to the output screen.
Sample Input:
Enter two strings Welcome welcome
Output:
The Strings are not equal.
• Develop a C program to find the number of occurrences of each alphabet in a
string accepted from the user and display the same to the output screen. Assume
that the string contains only alphabets.
• Write a C program to accept the string from the user and then reverse string
without using the second string.
Input:
Enter the string: Artificial
Output: laicifitrA
Week 5: (Pointers)
• Design a UDF in C to find the product and quotient of two numbers passed to it
from the calling program. Display the product and the quotient in the main
program. Read the two numbers in the main program & also display their product
and quotient. Implement using a pointer.
• Write a C program to accept & store N real numbers into an array. Find their mean
and standard deviation using pointers and display the same to the output screen.
Sample Input:
N=9 Array[ ] = {22, -3, 11, -2, 5, 7,12,13, 18}
Output:
Mean μ : 9.22 Std. Deviation: 7.91
Hint: Use Std. Deviation formula:
5.

N = the size of the population, xi = each value from the population µ = the
population mean.
• Write a C program to accept N integers from the user into an array. If any integer
is positive then subtract 2 from it, if integer is negative add 1 to it and if zero then
do nothing. Implement a UDF using a pointer to perform these operations and
finally display the modified array to the screen in the calling program.
Sample Input:
1 3 -5 0 8 -4 -1
Output:
-1 1 -4 0 6 -3 0
Week 6: (Pointers & Strings)
• Design a UDF using pointer that returns 1 if the string is a palindrome otherwise
zero. Accept a string from user in the calling program. Display an appropriate
6.
message in the calling program. Implement a C program for the same. Ignore
the case.
Sample Input/Output:
Input:
Enter a String: Rotator
Output:
Rotator is a palindrome
• Design a UDF that returns the count of special characters present in a sentence
passed to it using pointer to the calling program. Implement a C program to read
a string in the main program and display all the count of the special characters
returned by the function to the console.
Sample Input:
Enter a String: Rotation%# is$? ?rotating $motion?
Output:
Special Character Count: 10
• Design a UDF that takes a single string and a character present in the string as
its argument, then it returns an index to the first occurrence of the character to
the string. Write a C program to read a sentence in the main program and display
the string from the index returned by the UDF using a pointer to the console.
Sample Input:
Jack and Jill went up the hill
Search Character: ‘w’
Output: went up the hill
Week 7: (Pointers)
• Write a C program to dynamically allocate memory for an integer array of size N,
allow the user to input N integers, resize the array to N+M using realloc to add M
more integers, compute the sum of all N+M integers, and properly release the
allocated memory.
• Write a C program to dynamically allocate memory for two user-input strings,
7. concatenate them into a new dynamically allocated string, print the result and free
all allocated memory.
• Write a C program to dynamically allocate memory for an array to input N integers
and then create a second dynamically allocated array to store only the prime
numbers of the N integer array. Print the resultant array and free all the allocated
memory.
Week 8: (Structures)
• Develop a program in C to read a structure in the main program of an Employee
that contains Name, EmpCode and Salary as the members. Write a function to
display the details of the employee in the following format.
ABCCorporation
Name : Aman Singh
8. Bha
EmpCode : E211

Nett.Salary : Rs.1,25,000
-
• Develop a C program to read the attributes of an item from the user such as
ItemCode, ItemName, Quantity and Rate. Implement a C program using a
structure to find the total cost of the inventory of storing N items in the stock.
• Develop a C program to find total and average sales of 'N' employees by reading
the details such as empcode, name, and sales using array of structures.
Week 9: (Structures and Union)
• Develop a C program to display Name, Roll Number, Date of Birth and Date of
Admission details of a student read from the keyboard where the date of birth
and date of admission further consists of three members such as day, month and
year in a separate structure. Implement using a C structure.
• Develop a C program to read the following details of N employees into
9.
appropriate data storage. EmpNo, Name and Salary. Display all the details of the
employees in the descending order of their salary to the console.
• Write a C program to define a union with fields int id, float salary, and char
name[20], input values for each field, print the stored values, and demonstrate
how the union can hold only one value at a time by modifying and printing the
fields.

Week 10: (File Handling)


• Write a C program to create a file ThreePara.txt and write any three paragraphs
of text to it. Display the content of the file and the count of frequency of
consonants and vowels present in it to the console.
Note: You may assume a single paragraph in the input stream until you
10. encounter a newline character (\n).
• Develop a C program to create a file and copy its contents to another file such
that there is no space between any of the words in the copied file. Display the
content of the newly copied file to the output screen.
• Write a C program to count the number of words, characters, and lines in a text
file.
Week 11: (File Handling)
• Design a C program to add to an existing file present in the current drive by
reading the contents from another file. Read the names of both the files from the
user. Display the new file to the console by converting all the alphabets to
lowercase.
• Implement a C program to read 20 integers through command line arguments
and store them into a file Numbers.txt in the current working path. Then read the
file Numbers.txt and separate them into two different files odd.txt and even.txt
such that odd numbers are copied to odd.txt and even numbers are copied to
11. even.txt files respectively in the same current working path.
Sample Input:
D:\….> Numbers 12 11 13 18 119 122 18 24 25 39 37 42 45 50 55 56 58
60 75 77
Sample Output:
File: Numbers.txt: 12 11 13 18 119 122 18 24 25 39 37 42 45 50 55 56 58 60 76
77
File: odd.txt: 11 13 119 25 39 37 45 55 77
File: even.txt: 12 18 122 18 24 42 50 56 58 60 76
Week 12: (File Handling)
12. • Assume a file "Paragraph.txt" is present in the current drive & then read the file
and then convert all the vowels into uppercase and the display the modified file
to the console. Implement using a C program.
• Write a C Program to read a sentence from the user, later copy that sentence to
a file “Data.txt” present in the current drive and then display the contents of the
file in reverse to the screen.
• Write a C program to create a Book structure to store title, author, and price, input
details for three books, store them in a file, read the file to find the most expensive
and lowest priced books, and display their information.
Week 13: (Python Programming)
• Design a function in python that returns the real quotient and the remainder to
the calling program. Display the quotient and the remainder to the console.
Sample Input:
Enter two numbers: 628 25
Sample Output:
The quotient is: 25.12
13. The remainder is: 3
• Design a function in python that returns the concatenated string and its length to
the calling program. Display the joined string and its length to the console.
Sample Input:
Enter the first string: Tic Tac
Enter the second string: Toe
Sample Output:
The joined string: Tic Tac Toe
Length of new string: 11
Week 14: (Python Programming)
• Develop a program in python to read an entire text file and display the number of
special characters present in it to the screen.
• Write a python program to find & display all the occurrence of words starting with
the letters a, c, d, g, p and s read in a file from the user to the screen. Assume
articles or single letters also as words. Ignore the case.
Sample Input: input.txt
14. Content of the file:
Can you design this game in python assume there are two players one of them
hides a four-letter code say R, G, B, Y, V represent the first letters of the code
that are allowed
Output:
Can design game python assume are players a code say code are allowed
• Design a function in Python to copy N lines from a file Sample.txt present in the
current drive to another file Chunk.txt. Display the contents of Chunk.txt to the
screen.
Total 40

You might also like