Anda di halaman 1dari 7

CPU

2ND SEM CPU

TUTORIAL

TUTORIAL 1: (FUNDAMENTAL C VARIABLES, ESCAPE SEQUENCE ETC…)

1. Write a Program to display your Name and Address using printf (\n and \t)
1
1. Write a Program for Addition, Subtraction, Multiplication, and Division of two nos.
2
1. Write a Program for temp. conversion from Fahrenheit to Celsius.
3
1. Write a program for swapping two nos. entered by user.
4
1. Write a program to convert given days into no. of months and remaining days. e.g.
5 65 days = 2 months & 5 remaining days

TUTORIAL 2: (CONDITIONAL STATEMENTS IF, ELSE)

2. Enter value and check it is less, equal or greater than zero.


1
2. Input 2 number and print the maximum among them. (without If statement)
2
2. Input 3 number and print the maximum among them.
3
2. Input a number & print the number is odd or even.
4
2. Get a character in lower case form user and display it in upper case.
5
2. Get a character from user and check whether it is vowel or consonant
6

TUTORIAL 3: (SWITCH STATEMENTS)

3. Write a Program to enter the marks of five subjects and display the result according
1 to Distinction, First Class, Second Class, Pass Class and Fail.
3. Write a program to provide multiple functions such as addition, subtraction,
2 multiplication, division, remainder, and exit using switch () statement.
3. Write a program to convert years into months, days, hours, minutes and exit using
3 switch() statement.

-1-
CPU

TUORIAL 4: (LOOPING STATEMENTS)

4.1 Write a program to print nos from 1 ....10 using while, do…while and for loop.
4.2 Write a program to print the nos from 1....10 in series as 1,10,2,9,3,8,4,7,5,6.
4.3 Write a program to accept one no from user and display its factorial.
4.4 Write a program to print 0 1 1 2 3 5 8 13 21 34 55 ....(Fibonacci series)
4.5 Write a program to accept one no from user and find if it is prime or not.
4.6 Write a program to display following pattern:
1
22
333
44444
555555
4.7 Write a program to display following pattern:
*
**
***
****
*****
4.8 Write a program to display the following pattern.
1
01
101
0101
10101
4.9 Write a program to reverse the given integer no.
4.1 Write a program to calculate average of nos entered by user until 999 using break
0 statement. (i.e. enter no. 999 to stop the input).

TUTORIAL 5: (ARRAYS)

5. Accept 5 numbers in an array and display it.


1
5. Accept 10 numbers in an array and store it in another array.
2
5. Accept 10 numbers in an array and find total of positive and negative no.
3
5. Write a program to print string in the reverse order. e. g. HELLO would give result
4 as OLLEH.
5. Write a program for matrix addition.
5
5. Write a program to sort an array of 10 elements.
6

-2-
CPU

5. Accept values in 3 X 4 array and find out row total, column total, Maximum,
7 minimum and total.
5. Write a program to read Two matrices and multiply them.
8

TUTORIAL 6: (STRINGS)

6. Perform all the programs with string library functions and without string library
1 function.
6. Write a program to find length of a string.
2
6. Write a program to compare two given strings.
3
6. Write a program to reverse the given string.
4
6. Write a program to merge (or concat ) two strings.
5
6. Write a program to copy one string to another.
6

TUTORIAL 7: (FUNCTIONS)

7. Write a program to find sum of three numbers using functions.


1
7. Write a function power that computes x raised to the power y for integers x and y
2 and returns double type value.
7. Write a program to generate Fibonacci series using recursion.
3
7. Write a program or function which should work like a strrev() function.
4
7. Swap to numbers by call by reference method and display the number before, during
5 and after the function calling.

TUTORIAL 8: (POINTERS)

8. Write a program to print the address of a variable along with its value.
1
8. Write a program to generate table of given number using pointer.
2
8. Write a program to illustrate use of pointers in arithmetic expression.
3
8. Write a program using pointers to determine the length of a character string.
4

-3-
CPU

TUTORIAL 9: (STRUCURES)

9. Define a structure called cricket that will describe the following information:i.
1 Player Name
ii. Team Name
iii. Batting Average
Using cricket, declare an array player with 50 elements and write a program to read
the information about all the 50 players and print team-wise list containing names of
player with their batting average.
9. Write a program to enter and display the employee data using nested structure.
2
9. To enter the member field of structure student and display content of it.
3

SECTION 2 C++

TUTORIAL 10 (CLASS CONCEPTS)

10. Develop a class Student which has the class member rollno & class functions
1 getrollno() & printrollno().
10. Create a class Distance with data members as Inch and Feet. Develop a member
2 function to get values of feet and inch. Display value and add two distance objects.

TUTORIAL 11(CONSTRUCTOR OVERLOADING, COPY CONSTRUCTOR ,


DESTRUCTOR , COPY CONSTRUCTOR)

11. Create a class triangle with member variable char, two constructor; one with no
1 argument which initialize the char member to ‘*’ and one with one char argument.
Write a member function print_tri which prints triangle of given char. Take the no
of lines as an argument to print_tri function.
11. Write a class COMPLEX that has two member data, Real and Imaginary and write
2 overloaded constructors for three different kinds of object creation.
i) Object1 (), /* default values are real=0.0 and imaginary=0.0*/
ii) Object2 (2.3),/* default value for imaginary=0.0*/
iii) Object3 (2.3, 6.7)
Write necessary member functions.
11. Write a destructor for the class COMPLEX and observe the whole program with
3 "debugging (F-7)” utility.

-4-
CPU

11. Write a copy constructor for the class COMPLEX


4
11. Create a class which keeps track of the no. of its instances. Use static data member,
5 constructors and destructors to maintain and update information about active
object. Define static member function in class and use it in a program.

TUTORIAL 12(FRIEND FUNCTION, DEFAULT ARGUMENT, OPERATOR


OVERLOADING)

12. Define two classes METER and KILOMETER with data member Dist
1 representing distance in meter and km respectively. Develop an ADD function to
add objects of both classes and return distance in METER.
12. Write a function for finding area of circle, rectangle. Names of both functions must
2 be same ‘AREA’.
12. Write a function POWEROF with two argument named base and exponent and call
3 the function in three ways given below.
Call result
i) POWEROF(4,5) 1024
ii) POWEROF(3) 27
iii)POWEROF() 8
12. Develop a class STRING which has member data as character array. Overload the
4 operator '+' which acts same as the function strcat () Such as:
String S1 = "Destination"
String S2 = "Clarity"
String S3 = S1 + S2
After execution of last statement, the object S3 would have content
"DestinationClarity".
12. Create a class distance with data as Inch and Feet and develop member function to
5 insert values, display distance and overload ‘–‘and ‘+’
operator to perform following operation.
I) N = D1 – D2.
II) D3= D2 + D1.
III)D4 = D1 + N2.
(N1, N2 are integer values and D1, D2, D3, D4 are objects of distance class.)

TUTORIAL 13(FRIEND OPERATOR OVERLOADING AND TYPE CASTING)

13. Create a class time with hours, minutes and seconds.


1 Write a program that performs following operations:
I) t2=t1+n (add n seconds in time t1 and store in t2)
II) t3=n+t1 (add time t1 in n seconds and store in t3)
13. Write a function to overload insertion and extraction operators to input and output
2 data for employee [no, name and salary]. Why it is necessary to declare these
function as a friend function.

-5-
CPU

13. Define classes CARTESIAN with data members as x and y coordinates and
3 POLAR with data member radius and angle. Write a program to convert Cartesian
coordinates to polar coordinates and vice versa.
13. Define a class TON having data member ton and another class KG having
4 kilogram and gram as data members. Write a program to convert object of TON
class to KG class and vice versa.
13. Write a program that consists of two classes TIME12 and TIME24. The first one
5 maintains time on a 12 hour basis, where as other one maintaining time on a 24-
hour basis. Provide a conversion function to carry out the conversion from object
of one type to another.

TUTORIAL 14(INHERITANCE)

14. Define a class EMPLOYEE which has first name and last name as the data
1 members. Derive a class HOURLY-WORKERS with wage and hours as data
members and function get_pay () which calculates and returns total_pay. Write a
program to input data and print it with total pay.
14. Create a class Institute (name, address, city). derive a class Branch (name, total no
2 of students, no of faculties, placement percentage). derive a class Student (name,
reg no, aggregate, address, city). Write appropriate member functions.
14. Create a class a class YDS with data members president_name, secretory_name.
3 Create two classes AIP (principal, no of students) & AITS (principal, no of
students, no of branches) that inherits the YDS class. Create objects of AIP &
AITS & access member functions of YDS class and own.
14. Create a class student as a virtual base class with no. and name as Data member.
4 Derive test and sports classes from students with marks of three subjects and score
respectively. Derive a result class from test and sports with total no. of marks and
score in sports. Print output.
14. Define a base class called SHAPE. Use this class to store two double type values
5 that could be defined used to compute the area of figures. Derive two specific
classes called TRIANGLE and RECTANGLE from thebase SHAPE. Add to the
base class, a member function get_data () to initialize base class data members and
another member function display_area () to compute and display the area of
figures. Make display_area () as a virtual function and redefine this function in the
derived classes.
Using these three classes design a program that will accept dimensions of a
triangle or rectangle and display the area.

-6-
CPU

-7-

Anda mungkin juga menyukai