Certificate: Internal Examiner External Examiner
Certificate: Internal Examiner External Examiner
Certificate: Internal Examiner External Examiner
Principal
Place: Pune Date:
Suryadatta College Of Management Information Research & Technology
Index
Student's Faculty's
Sr. No. Practical Name Pg No. Date Remark
Sign Sign
1
Subject a nd pecenta ge a l s o pri nt pa s s or fa i l
2
Area a nd peri meter a nd s qua re a nd recta ngl e
3
Ma xi mum no. a nd s qua re of ma xi mum no.
4
Check wether no. i s pri me or not
5
GCD of two i ntegers
6
Addi ti on of a rra y el ements
7
Fi nd a n el ement i n a rra y
8
Ca l cul a te n fa ctori a l
9
Stri ng l i bra ry functi on
10
Fi bona cci s eri es from fi rs t 25 numbers
11
Swi tch ca s e performs ma ths opera ti on
12
2 di mens i ona l a rra y i n ma tri x
13
Demons tra te us e of s tructure to fi nd s tudents na me
14
Cl a s s s tri ng us i ng di fferent cons tructor
15
Cl a s s a nd member funti on us e of a rra y objects
16
Crea te cl a s s us i ng functi on overl oa di ng
17
Two cl a s s es us i ng functi on overl oa di ng
18
Us i ng functi on overl oa di ng
19
Mul ti l evel i nheri ta nce to s tore s tudent i nforma ti on
20
Runti me pol ymorphi s m
Start date: Practical no:
Que1.Write a Program which take a input marks obtain in 4 subject and print marks obtain in
Subject and percentage (in float) also print student is pass or fail (student is fail if he/she
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
Void main()
Clrscr();
int chem,phys,IT,maths;
float T,total,per;
total=chem.+phys+IT+maths;
printf(“total is %f”,total);
T=400;
per=(total/T)*100;
Printf(“percentage is %f”,per):
if(per>=35)
printf(“congrats”);
else
printf(“sorry”);
getch();
}
OUTPUT:
35
35
35
Total marks=140
Percentage=35%
Congrats
2. Write a C program find the Area and Perimeter and Square and Rectangle
SOURCE CODE:
#include<stdio.h>
void main()
clrscr();
int length,breadth,peri,area,side,peri2,area2;
area=length*breadth;
peri=(2*length)+(2*breadth);
printf(“Area=%d perimeter=%d”,area,peri);
scanf(“%d” ,&side);
area2=side*side;
peri2=4*side;
printf(“Area2=%d perimeter=%d,area2,peri2);
getch();
}
OUTPUT:
Area=24 perimeter=28
3. Write a C program find the find max, Among 3 integer numbers. And also print square of
SOURCE CODE:
#include<stdio.h>
void main()
int a,b,c;
clrscr();
if(a>b&&a>c)
else if(b>a&&b>c)
else
getch();
}
OUTPUT
2=4,8=64,1=1
4. Write a C program to check whether the number is prime or not(Write a function to check
number is prime).
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main()
clrscr();
int n,i,ans;
scanf("%d",&n);
for(i=2;i<n/2;i++);
ans=n%i;
if(ans==0)
else
getch();
}
OUTPUT:
SOURCE CODE:
#include<stdio.h>
void main()
int n,m,i,gcd;
for(i=1;i<=n&&i<=m;i++)
if(n%i==0&&m%i==0)
gcd=i;
printf(“%d %d %d”,n,m,gcd);
getch();
OUTPUT:
30
40
(Number of array element will be 5 and take the array element from user)
SOURCE CODE:
#include<stdio.h>
void main()
int a[5],i,sum=0;
clrscr();
for(i=0;i<=5;i++)
scanf(“%d”,&a[i]);
For(i=0;i<=5;i++)
sum=sum+a[i];
getch();
}
OUTPUT:
5,5,5,5,5
Sum=25
(Number of array element will be 5 and take the array element from user)
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main()
clrscr();
int a[10],size,i,search,flag;
scanf("%d",&size);
for(i=0;i<size;i++)
scanf("%d",&a[i]);
scanf("%d",&search);
flag=0;
for(i=0;i<size;i++)
if(a[i]==search)
flag=1;
break;
if(flag==1)
else
printf("sorry");
getch();
OUTPUT:
size of array=10
elements in array:10 12 20 25 13 10 9 40 60 5
SOURCE CODE:
#include<stdio.h>
void main()
int c,n,fact=1;
scanf(“%d”,&n);
for(c=1;c<=n;c++)
fact=fact*c;
printf(“Factorial of %d=%d\n”,n,fact);
getch();
OUTPUT:
Factorial=120
9. Write a C program to read two strings and explain string library function.
1)strlen()
2)strcyp()
3)strcat()
SOURCE CODE:
1:#include<stdio.h>
#<string.h>
voi d main()
char s1[10];
int l;
clrscr();
get s(s1);
l=strlen(s1);
printf(“length=%d”,l);
getch();
OUTPUT:
2.#include<stdio.h>
#include<string.h>
void main()
char s1[10],s2[20];
clrscr();
s1=amu
s2=omkar
strcpy(s1s2);
printf(“First string=”);
puts(s1);
printf(“Second string=”);
puts(s2);
getch();
OUTPUT:
First string=amu
Second string=omkar
3.#include<stdio.h>
#include<string.h>
void main()
char s1[10],s2[20];
clrscr();
gets(s1);
gets(s2);
strcat(s1,s2);
printf(“First string=”);
puts(s1);
printf(“Second string=”);
puts(s2);
getch();
OUTPUT:
James Bond
10.Write a C program to which contain function to obtain first 25 numbers of a Fibonacci series.
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main()
clrscr()
int n, i, a=0,b=1,c;
printf("Enter a number=");
scanf("%d" ,&n);
c=a+b;
printf("%d,"c);
a=b;
b=c;
getch();
}
OUTPUT:
Enter a number=25
0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,
11. Write a C program using switch case which perform math’s operation (+,-,*, /, %)
SOURCE CODE :
#include<stdio.h>
void main()
char a ,b ,c , ch;
clrscr();
scanf("%d", &a);
scanf("%d", &b);
scanf("% s, &ch);
switch(ch)
{
case +: c=a+b
printf ("Addition=%d",c);
break;
case - : c=a-b;
printf("Subtraction=%d",c);
break;
case * : c=a*b;
printf("Multipication=%d",c);
break;
case / : c=a/b;
printf("Division=%d",c);
break;
case % : c=a%b
printf("Modular = %d",c);
break;
break;
getch();
OUTPUT:
1.Addition
2.Subtraction
3.Multiplication
4.Division
Result=0.857143.
12. Write a C program to display an element of 2 dimensional arrays in matrix form. (Array
SOURCE CODE:
#include<stdio.h>
void main()
int a[3][3],i,j;
clrscr();
printf(“Enter a matrix);
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf(“%d”,&a[i][j]);
printf(“matrix=”);
for(i=0;i<3;i++)
for(j=0;j<=3;j++)
printf(“%d/t”,a[i][j]);
printf(“\n’);
}
getch();
OUTPUT:
Array=
1 2 3
4 5 6
7 8 9
13. Write a C program demonstrate use of structure declare following structure and write m
menu driven program display student info and to find student name in data
SOURCE CODE:
#include<stdio.h>
#include<string.h>
strct student
{
int id;
int main ()
s1.id=101;
//S2.id=102;
printf(“student 1 id:%d\n”,S1.id);
printf(“student 2 id:%d\n”,s2.id);
printf(“student 2 name:%s\n”,s2.mane);
return 0;
}
OUTPUT:
14. . Define a class string. Use different constructors and do the following [20
marks]
SOURCE CODE:
#include<iostream.h>
#include<string.h>
using namespace
int main()
String str1=”hello”;
String str2=”world”;
String str3;
int len;
Str3=str1;
Cout<<”str3;”<<str3<<endl;
Len=str3,sice();
Cout<<:str3.size():”<<len<<endl;
return 0;
}
OUTPUT:
String=helloworld
Size=10
16. Write necessary class and member function definitions for a cricket player object.
The program should accept details from user (max 10) : player code, name, runs,
SOURCE CODE:
#include<iostream.h>
#include<string.h>
#include<conio.h>
class scorecard
Char batname[11][20];
int runscored[11];
char situation[11][20];
char mode[11][15];
char bowlernamned[11][20];
float oversplayed[11];
int maiden[11];
int runsgiven[11];
int wicketstaken[11];
public:
void updatebatman(void);
void updatebowler(void);
void displaybat(void);
void displaybowl(void);
void menu(void);
scorecard()
for(int n=0;n<12;n++)
runscored[n]={0};
oversplayed[n]={0};
maiden[n]={0};
runsgiven[n]={0};
wicketstaken[n]={0};
};
int main()
int jb=0;
scorecard s1;
int kb;
s1 menu();
do
Cin>>kb;
switch(kb)
Case1:s1.displaybat();
break;
Case2:s1.displabowl();
break;
Case3:s1.upadatebatsman();
break;
Case4:s1.upadatebowler();
break;
default.cout<<”Wrong choice”;
While(jb<1);
{char bowlname[20];
cin.getline(bowlername[k],bowlname);
if (str==0)
cin>>option;
switch(option)
cin>>overnumbers;
cout<<endl;
overesplayed[k]+=overnumbers;
break;
cin>>maidenumb;
cout<<endl;
maiden[k]+=maidenumb;
break;
cin>>uprun
cout<<endl;
runsgiven[k]+=uprun;
}
break;
cin>>upwicket;
cout<<endl;
wicketstaken[k]+=upwicket;
break;
default;cout<<”wroung choice”;
break;
if(str!=0)
{char batsmen[20]
int str.k;
void scorecard::updatebatsman(void)
{char batsmaname[20];
int str,k;
cin.getline(batsmaname,20);
for( k=0;k<11;k++)
{str= strcmp(batname[k],batsmaname);
if (str== 0)
cin>>runscored[k];
cin>>situation[k];
cin>>mode[k];
break;
if (str!=0)
}
void scorecard::displaybat(void)
for(int j=0;j++;j<12)
cout<<batname[j]<<'t'<<runscored[j]<<'t'<<situation[j]<<'t'<<mode[j]<<endl;
void scorecard::displaybowl(void)
cout<<endl;
for(int j=0;j++;j<12)
cout<<bowlername[j]<<'t'<<oversplayed[j]<<'t'<<maiden[j]<<'t'<<wicketstaken[j]<<'t'<<runsgiven[j]<<e
ndl;
void scorecard::menu(void)
{
cout <<"Enter name of player "<<k+1<<":";
cin>>batname[k];
cin>>bowlername[n];
OUTPUT:
Runs of player=55
Runs of player=80
18. Create a C++ class mydate with three members dd,mm,yy. Write a menu driven
SOURCE CODE:
#include<isostream.h>
#include<conio.h>
class mydate
private:int date:
char month;
double year;
public:
void getdata(int i)
date=i;
cin>>I;
Month=m;
cin>>m;
}
Void getdata(double y);
Year=y;
cin>>y;
void display(int i)
cout<<”data”<<I;
void display(char m)
cout<<”month /”<<m;
void display(double y)
Cout<<”year”<<y;
void main()
clrscr()
mydata m1;
m1.getdata(int i);
m1.getdata(char m);
m1.getdata(double y);
m1,display(int i);
m1.disaplay(int m);
OUTPUT:
Accept two distances from the user, one in meter and centimeter and other in
feet and inches. Find the sum and differences of the two distances. Display
the result in both, meters and centimeters as well as feet and inches
SOURCE CODE:
#include<iostream.h>
//forward declaration
class B;
class A;
private:
int numA;
public:
A(): numA(12){}
};
return(objectA.numA+objectB,numb);
}
Int main()
A objectA;
B object;
cout<<”Sum:”<<add(objectA,object);
return 0;
OUTPUT:
Sum:13
20. Create a base class called Shape. Use this class to store two double values that could be
used to compute the area of figures. Derive three classes called as triangle, rectangle and
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
Using these four classes, design a program that will accept, dimensions of a triangle
and rectangle and radius of circle, and display the area.The two values given as input will
be treated as lengths of two sides in the case of rectangles and as base and height in the
Area of rectangle = x * y
Area of triangle = ½ * x * y
[In case of circle, get_data() will take only one argument i.e radius so make the second
SOURCE CODE:
#include<iostream.h>
#include<conio.h>
void main()
class shape
protected:
float width,height;
public:
void set_data(float a,float b)
width=0;
height=b;
};
public:
float area()
Return(width*height);
};
public:
float area()
{
return(width*height/2);
};
int main()
rectangle rect;
triangle tri;
rect.set_data(5,3);
tri.set_data(2,5)
return 0;
OUTPUT:
12
Area of rectangle=54
Area of triangle=13
21. Write a C++ program using multilevel inheritance concept which will display student
information ( Roll number ,marks obtain in two subject, total marks) use following
information
• Class student to get and put roll number, class test to get and put marks of two
SOURCE CODE:
#include<iostream.h>
#include<conio.h>
class student
char name[20];
public:
void get()
cin>>roll no;
cin>>first sub;
cin>>second student;
T=f+s
}
void show()
};
int main()
student s1;
s1.get()
s1.show();
return 0;
OUTPUT:
Total marks=100
(Title, price, number of pages) and Tape (Title, price, time). use following information
• Class media with parameter to initialize media information title and price & virtual
function display
• Class Book will inherit media & it will contain data member number of page and display
function
Class tape will inherit class media & it will contain data member time and display
function
SOURCE CODE :
#include<iostream.h>
class media
protected:
public:
Price=price1;
title=title1;
cout<<price;
cout<<title;
cout<<number of pages;
cin>>number of pages;
cin>>price;
cin>>title;
void display()
cout<<price<<price1;
cout<<title<<title1;
int time;
{
cin>>time;
void display()
cout<<title;
cout<<price;
cout<<title;
cout<<number of pages;
void main()
b1.getdata(8);
b1.display();
t1.accept(30 min);
t1.display();
getch();
}
OUTPUT:
number of page=15
price=100
title=A
number of pages1=15
price1=100
title1=50