Professional Documents
Culture Documents
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:
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
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.