Posts

Showing posts from May 3, 2020

Write A Program Simple Scope Resolution Operator Example Program In C++

  Write A Program Simple Scope Resolution Operator Example Program In C++ #include<iostream> #include<conio.h> #include<stdio.h> //Main Function using namespace std; int a = 100; //Global variable int main () {         // Local Variable Declaration     int a = 200;         cout << "Simple Scope Resolution Example Program In C++\n";         // Print Global Varibale     cout << ::a<< endl;         // Print Local Varibale     cout << a << endl;         //Main Function return Statement         return 0; } OUTPUT:- Simple Scope Resolution Example Program In C++                                                                                 100                                                                                                                            200 

Write A Program for Virtual Functions Using C++ Programming

Write A Program for Virtual Functions Using C++ Programming #include<iostream.h> #include<conio.h> class base { public:     virtual void show() {         cout << "\n   Base class show:";     }     void display() {         cout << "\n   Base class display:";     } }; class drive : public base { public:     void display() {         cout << "\n   Drive class display:";     }     void show() {         cout << "\n   Drive class show:";     } }; void main() {     clrscr();     base obj1;     base *p;     cout << "\n\t P points to base:\n";     p = &obj1;     p->display();     p->show();     cout << "\n\n\t P points to drive:\n";     drive obj2;     p = &obj2;     p->display();     p->show();     getch(); } OUTPUT:- P points to Base Base class display Base class

Write a Program for Static Data and Member Function Using C++ Programming

Write a Program for Static Data and Member Function Using C++ Programming #include<iostream.h> #include<conio.h> class stat {     int code;     static int count; public :     stat() {         code = ++count;     }     void showcode () {         cout << "\n\tObject number is :" << code;     }     static void showcount () {         cout << "\n\tCount Objects :" << count;     } }; int stat::count; void main () {     clrscr();     stat obj1, obj2;     obj1.showcount();     obj1.showcode();     obj2.showcount();     obj2.showcode();     getch(); } OUTPUT:- Count Objects: 2 Object Number is: 1 Count Objects: 2 Object Number is: 2

Write A Program For Parameterized Constructor In C++

Write A Program For Parameterized Constructor In C++ #include<iostream> #include<conio.h> using namespace std; class Example {     // Variable Declaration     int a, b; public:     //Constructor     Example(int x, int y) {         // Assign Values In Constructor         a = x;         b = y;         cout << "Im Constructor\n";     }     void Display() {         cout << "Values :" << a << "\t" << b;     } }; int main() {     Example Object(10, 20);     // Constructor invoked.     Object.Display();     // Wait For Output Screen     getch();     return 0; } OUTPUT:- Im Constructor                                                                                                                 Values :10      20  

Write A Program for Multiple Inheritance Using C++ Programming

Write A Program for Multiple Inheritance Using C++ Programming #include<iostream.h> #include<conio.h> class student { protected:     int rno, m1, m2; public:     void get() {         cout << "Enter the Roll no :";         cin>>rno;         cout << "Enter the two marks    :";         cin >> m1>>m2;     } }; class sports { protected:     int sm; // sm = Sports mark public:     void getsm() {         cout << "\nEnter the sports mark :";         cin>>sm;     } }; class statement : public student, public sports {     int tot, avg; public:     void display() {         tot = (m1 + m2 + sm);         avg = tot / 3;         cout << "\n\n\tRoll No     : " << rno << "\n\tTotal       : " << tot;         cout << "\n\tAverage     : " << avg;     } }; void main() {  

Write A Program for Multi level Inheritance Using C++ Programming

Write A Program for Multi level Inheritance Using C++ Programming #include<iostream> #include<stdio.h> #include<conio.h> using namespace std; class Employee {     int eno;     char name[20], des[20];             // Private members cannot call from outside class. public:     void getEmpDetails() {         cout << "\nEnter the Employee number:";         cin>>eno;         cout << "Enter the Employee name:";         cin>>name;         cout << "Enter the Employee designation:";         cin>>des;     }         void employee_display() {           cout <<"\nEmployee number:"<<eno;                    cout <<"\nEmployee name:"<<name;                    cout <<"\nEmployee designation:"<<des;     } }; class Salary : private Employee {           //Private Base Class, We cannot access out

write a program for in c++ using class

write a program for in c++ using class #include <iostream> #include<conio.h> using namespace std ; // Class Declaration class person {     //Access - Specifier public :     //Variable Declaration     string name;     int number; }; //Main Function int main () {     // Object Creation For Class     person obj;     //Get Input Values For Object Varibales     cout << "Enter the Name :" ;     cin >> obj.name;     cout << "Enter the Number :" ;     cin >> obj.number;     //Show the Output     cout << obj.name << ": " << obj.number << endl ;     getch();     return 0 ; } OUTPUT:- Enter the Name :mukul                                                                                                          Enter the Number :100