You are on page 1of 10

IMPORTANT QUESTIONS

PART A
1. Write a C++ program to find the sum of n natural number.

ANS:

2. What are the difference between constructor and destructor.

ANS:
3. How are object passes as argument to a function.

ANS:

4. What are the difference between classes and structure.

ANS:
5. Write a C++ program to swap two numbers.

ANS:
PART b
1. Explain different types of constructor in C++

ANS:
2. Describe object-oriented programming concept with an example.

ANS:
3. Create a C++ program which collects student information and use the concept of an
array of objects to determine the average mark.
ANS:
#include <iostream>
using namespace std;
class student{
public:
char name[20];
int reg,in;
int mark1;
int mark2;
int mark3;
int getinput(){
cin>>name;
cin>>reg;
cin>>mark1>>mark2>>mark3;
}
int putinput(){
cout<<"the name is:"<<name;
cout<<"the reg number is:"<<reg;
cout<<"The average is:"<<(mark1+mark2+mark3)/3;
}
};
int main() {
student s1[100];
for(int i=0;i<=4;i++){
s1[i].getinput();
s1[i].putinput();
}
return 0;
}

You might also like