1.
(a)
Write a C++ program to find the followings related to the students in a class of C++ Programming course.
(i) Average marks
(ii) Difference between highest marks obtained and the lowest marks obtained
(a)
Write a C++ program to find the followings related to the students in a class
of C++ Programming course.
(i)
Average marks
(ii)
Difference between highest marks
obtained and the lowest marks obtained (10 Marks)
Ans;
#include<iostream.h>
#include<conio.h> class
marks
{
int m1, m2,m3; int a,b;
public: void input(); void
disp(); int max(); int min(); };
void marks::input()
{
cout<<"enter
the mark"; cin>>m1>>m2>>m3;
}
int marks::max()
{
a=(m1>m2 ?m1 :m2);
b=(a>m3 ?a :m3); return b;
}
int marks::min()
{
a=(m1<m2 ?m1 :m2);
b=(a<m3 ?a :m3); return b;
}
void marks::disp()
{
cout<<"\nAverage
marks="<<(m1+m2+m3)/3; cout<<"\nDifference between max
and min="<<max()min();
}
void
main()
{
marks
ob; clrscr(); ob.input(); ob.disp(); getch();
}
(b)
Write a C++ program to create shape class having abstract method area(). Derive circle and rectangle classes from it. Override area method in circle and rectangle class to find the area of the respective shape.
(b) Write a C++ program to create shape class having
abstract method area(). Derive circle and rectangle classes from it. Override
area method in circle and rectangle class to find the area ofthe respective
shape. (10 Marks)
#include<iostream.h>
#include<conio.h> class
shape
{
int
a,b; public: void area(); };
class circle:public shape
{
float a,r; public: void
area()
{
cout<<"\nenter
the radius"; cin>>r;
a=(3.14*r*r);
cout<<"Area="<<a;
}
};
class rect:public shape
{
float a,h,w; public: void
area()
{
cout<<"\nenter the height & width";
cin>>h>>w;
a=(h*w);
cout<<"Area="<<a;
}
};
void main()
{
circle
ob; rect ot; clrscr(); ob.area(); ot.area(); getch();
}
2.
(a)
Write a C++ program to demonstrate exception handling in a program for matrix addition. Matrix addition function should notify if the order of the matrix is invalid, using exception.
(a) Write a C++
program to demonstrate exception handling in a program for matrix addition.
Matrix addition function should notify if the order of the matrix is invalid,
using exception. (10
Marks)
Ans:
#include <iostream.h>
#include<conio.h>
int
main()
{
int
I,j,a,b;
int first[5][5],second[5][5],add[5][5];
//declaration of a array clrscr();
try
{
cout<<”enter the no of row and
cols”; cin>>a>>b;
if(a>5 || b>5) throw;
for
( i = 0; i < a; i++ )
{
for
( j = 0; j < b; j++ )
{
cout<<"enter the number into
first array"; cin>>first[i][j];
}
}
//second array; Cout<<endl;
for
( i = 0; i < 2; i++ )
{
for
( j = 0; j < 2; j++ )
{
Cout<<"enter the number into
first array"; Cin>>second [i][j];
}
}
cout<<
"addition(first+second):”; for ( i = 0; i < 2;i++ )
{
for
( j = 0; j < 2; j++ )
{
add[i][j]=first[i][j]+second[i][j];
cout<<add[i][j];
}
Cout<<endl;
}
}catch(int)
{
Cout<<”invalid
matrix”;
}
getch();
}
(b)
Write C++ program to read the contents of a given file and display in on console.
(b) Write C++ program to read the contents of a given file
and display in on console.
|
(10
|
Marks)
Ans:
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
void main()
{
char x;
int v,c; v=0; c=0; clrscr();
ifstream
ot; ot.open("deepa.txt",ios::in); do
{
x=ot.get();
cout<<x;
}while(x!='@');
getch();
}
*********************END OF ASSIGNMENT************************
-----------------------------------------------------------------------------------------
Assignment Solution on process | IGNOU BCA MCA Solved Assignment 2016 2017 Join IGNOU BCA MCA Coaching Class | Synopsis & Project Support
Powered by IGNOUFriend | www.ignoufriend.co.in |
Assignment Solution on process | IGNOU BCA MCA Solved Assignment 2016 2017 Join IGNOU BCA MCA Coaching Class | Synopsis & Project Support
Powered by IGNOUFriend | www.ignoufriend.co.in |
ignou bca mca synopsis, ignou class, ignou bca mca project, solved ignou assignment,BCA Coaching Institute in Delhi, MCA Coaching Institute in Delhi, BCA MCA Coaching Institute in Delhi, BCA MCA, Tuation Class in delhi, IGNOU BCA MCA Class, IGNOU BCA MCA Tution,IGNOU Solved Assignment, IGNOU BCA Synopsis , IGNOU MCA Synopsis, ignou bca project, ignou mca project, ignou best coaching in delhi, ignou best coaching in new delhi, ignou best coaching in south delhi, ignou best coaching in north delhi, ignou best coaching in east delhi, ignou best coaching in west delhi
ignou, bca, mca, coaching institute, tution class, bcsp064, mcsp060, cs76, mcs044,bcs011, bcs012, mcs011, mcs012, mcs013, mcs015, bcsl021, bcsl022, mcs014, bcs040, mcs021, mcs023, bcs031, bcsl032, bcsl033, bcsl 034, bcs041, bcs042, mcsl016, bcsl043, bcsl044, bcsl045, bcs051, bcs052, bcs053, bcs054, bcs055, bcsl056, bcsl057, bcsl058, bcs062, mcs022, bcsl063, project
mcsp060, mcse011, mcse004, mcse003, mcsl054, mcs053, mcs052, mcs051, mcsl045, mcs044, mcs043, mcs042, mcs041, mcsl036, mcs035, mcs034, mcs033, mcs032, mcs031, mcsl025, mcs024, mcs023, mcs022, mcs021, mcsl017, mcsl016, mcs015, mcs014, mcs013, mcs012, mcs011
nips institute, nipsar, ignoufriend.in, ignoufriend.co.in, ignouhelp, best coaching institute
No comments:
Post a Comment