Sei sulla pagina 1di 5

Dharmsinh Desai University, Nadiad

Faculty of Technology
Department of Computer Engineering
Practical List
B. Tech CE, Semester: II
Subject: Computer Programming II
Last updated on: 02-MARCH-2015
Lab 1:
Core:
Write a program to find the average of n numbers using array. Support maximum 10
numbers.
Write a program to display binary representation on the screen of input positive
decimal number.
Write a program to represent internal voting software system. The election is contested
by 7 candidates. Candidates are numbered from 1 to 7. Voter presses any number
between 1 to 7 to elect or 0 to agree upon right to reject. Display the result with
winner candidate number unless the right to reject votes are higher than the highest
collected votes by any candidate. Display re-election message if needed.
Write a program to read dimensions and data of two integer matrices. Perform addition
of both if mathematically possible and display the result. Support maximum dimension
10x10.
Plus:
Write a program to read 3x3 integer matrix as input, generate transpose matrix of the
original matrix. Display transpose matrix on the screen. Extend to achieve variations like
displaying directly on the screen, performing in place transpose, etc.
Write a program to read two 3x3 integer matrices as input, generate multiplication two
matrix as result. Display result matrix on the screen.
Lab 2:
Core:
Write a program that reads a string from keyboard and determines whether the string is
palindrome or not. A string is a palindrome if it can be read from left and right with the
same meaning. i.e. madAm, anna. Ignore capitalization.
Write a program to read line of text from the keyboard and print out the number of
occurrences of given sub string using function strstr from library.
Write a program to decide and displaywhether student is eligible to enroll to CPC or
not. Take input firstname, middlename, lastname and branch. If student branch is any one
from [Computer,Mechanical,Information] then display welcome message as
Welcome <initial>. You are enrolled as <fullname>. Max fullname allowed is 25
characters. (use string library functions)
Plus:
Write a program that reads cost of item in the form RRRR and converts the value to a
string of words that express the numerical value in the words. i.e. 3549 can be read as
Three Thousand Five Hundred Forty Nine.

Lab 3:
Core:
Develop modular based program to achieve following:
MULTIPLICATION TABLE
Element of the table indicates multiplication of row with column index.
******************************
-----------------------------1 2 3 4 5 6 7 8 9 10
-----------------------------2 4 6 8 10 12 14 16 18 20
-----------------------------3 6 9 12 15 18 21 24 27 30
-----------------------------4 8 12 16 20 24 28 32 36 40
-----------------------------5 10 15 20 25 30 35 40 45 50
-----------------------------6 12 18 24 30 36 42 48 54 60
-----------------------------7 14 21 28 35 42 49 56 63 70
-----------------------------8 16 24 32 40 48 56 64 72 80
-----------------------------9 18 27 36 45 54 63 72 81 90
-----------------------------10 20 30 40 50 60 70 80 90100
-----------------------------******************************
Achieve following requirement using recursive function definition:
Find factorial of a given number
Display binary representation of decimal input number
Bubble sort using function.
Plus:
Write a program to solve the series using user defined functions: 1 / 1! + (3)^3 / 3! +
(5)^5 / 5! + ... + (n)^n / n!. Here, n is a positive integer entered by user. Extend the
factorial function to behave smart-fully.
2

Lab 4:

Structures and Unions


Core:
Write a C program using structures to read the following information of 10 employees.
name,id,experience(in years) and salary. The program should print the id and name of all
employees who have 7 years or more experience but salary less than 12,000.
Represent a point p(x,y) using structure. Write a function addpoint(..) to add
two points and return the result point. Same way write another function
ptinrect() with two arguments a point and a rectangle , it returns true if the point within
the rectangle otherwise returns false.
Design a Multiple Choice Question Option with below details:
Structure mcqoption : int id, int type, union data
Here, data can itself be designed efficiently using union where it can be a char if type 0,
int if type 1, float if type 2 or string if type3.
Plus:
Write a program to represent date as a data type and let programmer do different
operations on dates mentioned below. (For your information: In programming world,
'date' data type normally means date and time together. If time is not provided or not
needed to be displayed in the format then midnight 00:00:00 is used by default.).
Date setDate(int MM, int DD, int YYYY,int
sets all members of date instance and returns it.
String
toString(Date
Converts the date instance into a string and returns the result.

HH,int

MM,

int

SS)
date)

MM/DD/YYYY HH:MM:SS
boolean
after(Date
date1,Date
date2)
Returns true if the date1 instance contains a date that is later than the one specified by
date2 instance, otherwise, it returns false.
boolean
before(Date
date1,
Date
date2)
Returns true if the date1 instance contains a date that is earlier than the one specified by
date2 instance, otherwise, it returns false.
boolean
equals(Date
date1,Date
date2)
Returns true if the date1 instance contains the same time and date as the one specified by
date2 instance, otherwise, it returns false.
Write a driver program to utilize above time library.
Read two person's birth date and display whether they born same day and time. Otherwise
display who is elder and who is younger.

Lab 5:

Pointers
Core:
Swap/exchange values of two integer variable arguments using function. Use pointer.
Write a function that compares two integer arrays to see whether they are identical. The
function returns 1 if they are identical, 0 otherwise. Develop different versions of
function. One via traversing array via pointer, second via pointer and offset, third via
array index notation.
Sorting of set of strings using pointers. Do not sort actual strings from their memory.
Just manipulate pointers. [Use string constants to initialize data.]
Plus:
Write function that receives a sorted array of integers and an integer value, and insert
the value in its correct place.
Populate a two dimensional array with contents as a spiral. Utilize pointer arithmetic
and the relation between array and pointer.
i.e for 5X5
1 2 3 4

16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
Lab 6:
Arrays, Strings, Functions, Structures and Pointers All in one
Core:
you are supposed to generate a result table which consists of student id, student name,
marks of three subject and total marks. Write a program which takes input for ten
students and displays result table. Finally, provide menu to sort and re-display based on
choice of field and ascending or descending. Update this sort technique till three levels,
i.e. sort by id then name then total marks if chosen this way.
Plus:
Write a method to decide if two strings are anagrams or not.
Anagram: a word, phrase, or name formed by rearranging the letters of another, such as
spar, formed from rasp.
Lab 7:
Pointers and Strings
Core:
Implement your string library using pointers. Use constant pointer and pointer to
constant and pointers arithmetic wherever needed. [You may practice multi-files
programming as well.]
4

mystrlen, mystrcpy, mystrcmp,mystrncpy, mystrmncmp, mystrstr.


Plus:
Implement wc command for input text using pointers.
Lab 8:
Files and command line arguments
Core:
Write a program to take input student registration details for the tech event and store
into file event.txt. Provide a menu to read from file and display formatted list with
existing registration and total number of registration till now.
Separate integer binary file into two different Odd.dat and Even.dat which contains the
corresponding odd or even numbers. Display list of all even numbers followed by all odd
numbers.
List and display all command line arguments on new line. Implement simple command
line calculator.
Plus:
Write a program which calculates no. of characters, words, and lines of the input file.
Use command line argument to get the input file name;
Write a program to sort a nXn matrix elements in ascending order.
Lab 9:
Dynamic memory allocation
Core:
Sorting of set of strings using pointers. Do not sort actual strings from their memory.
Just manipulate pointers. [Read strings as input from user and allocate memory on
runtime.]
Write a program to store a character string in a block of memory space created by
malloc and then modify the same to store large string.

Plus:
Write a program to create and display linked list.

Lab 10:
The pre-processor
Core:
Develop macros to find maximum, minimum of two numbers.
Demonstrate the risk factors of using macro via example.
Plus:
Demonstrate use of nesting of macro via example.

Potrebbero piacerti anche