Posts

#8 | C++ | Input one number in a class and input another number in another class. Find summation between these numbers using a friend function.

Image
      CompTech  C++ Practical Assignment #practical 8 YouTube Video :-  Question :-  Input one number in a class and input another number in another class. Find summation between these numbers using a friend function. Code :- /* practical 5 Write a program to input one number in a class and input another number in another class. Find summation between these numbers using a friend function. */ #include <iostream> using namespace std; /* when we work with more than one class then we have to declare the class name first, so that, we will not face any type of error */ class xyz; // declaring second class "xyz" // defining class "abc" class abc {     // Declare variable in private section to store one value     int n1;     // public :- declare two function     // 1. Member function - getdata() - assign the value to variable     // 2. Friend function - summation() - calculate the sum     public:         // Declaring and defining member function inside the clas

#7 | C++ | Write a program to calculate Simple Interest using friend function The input must be taken in a member function designed outside the class.

Image
    CompTech  C++ Practical Assignment #practical 7 YouTube Video :-  Question :-  Write a program to calculate Simple Interest using friend function The input must be taken in a member function designed outside the class. Code :- /* 4. Write a program to calculate Simple Interest using friend function. The input must be taken in a member function designed outside the class. */ #include <iostream> using namespace std; // Cretae class Simpal Interest class Simpal_Interest {     //Declare the Variables to store data in Private Section     // p = Principal Amount     // r = Rate of Interest     // n = Number of Years     int p,r,n;     float si= 0 ;     // Public section, declare member function and friend function     public:         void getdata();         friend void display(Simpal_Interest); }; // Define the body of member function getdata() void Simpal_Interest :: getdata() {     // Pass the message to user to Enter the values and     // Store them in our variables    

#6 | C++ | Write a program to input three numbers in a member function and display maximum number using friend function.

Image
  CompTech  C++ Practical Assignment #practical 6 YouTube Video :-  Question :-  Write a program to input three numbers in a member function and display maximum number using friend function. Code :- /* 3. Write a program to input three numbers in a member function and display     maximum number using friend function.*/ #include <iostream> using namespace std; class maximum {     // This three variable are in private section.     // They will store the value of three numbers.     int a,b,c;     /* In public Section, We will declare two functions         1. Member Function -> getdata() -> Get The Value from the user and store in variables         2. Friend Function -> max() -> Find the maximum Number from three numbers.     */     public:         void getdata();         // friend function is only declare in class         // It can not be define in class         // Declare friend function using "friend" keyword.         // In this we have to pass the class

#5 | C++ | Write a Program to input price of two products in a member function and display total bill using friend function.

Image
CompTech  C++ Practical Assignment #practical 5 YouTube Video :-  Question :-  Write a Program to input price of two products in a member function and display total bill using friend function. Code :- // Write a Program to input price of two products in a member function and display total bill using friend function. #include <iostream> using namespace std; class billing {     // declare variables in Private Section     int pro1,pro2;     //In Public Declare member function and friend function     public:         void getdata();         friend void display(billing); }; void billing :: getdata() {     cout<< "Enter Price :- " ;     cin>>pro1;     cout<< "Enter Price :- " ;     cin>>pro2; } void display(billing b) {     int total= 0 ;     total = b.pro1 + b.pro2;     cout<< "\t- Your Total Bill = " <<total; } int main() {     billing b;     b.getdata();     display(b); } Description :- - Let's Create on

#4 | C++ | Write a Program input item name, lot number, Quantity and price for a class "Item" and display the details. (using Array of Objects).

Image
CompTech  C++ Practical Assignment #practical 4 YouTube Video :-  Question :-  Write a Program input item name, lot number, Quantity and price for a class "Item" and display the details. (using Array of Objects). Code :- // 1. Write a Program input item name, lot number, Quantity and price for a class // "Item" and display the details. (using Array of Objects) #include <iostream> using namespace std; // Creating "Item" Class class item {         // Declaring variable In Private Section name, lot number, Qunatity and price         char name[ 50 ];         int lot_num;         int quan;         int price;         /* Declaring Function in public section         1. Getdata() That will collect the data from user         2. display() that will display all the data         */         public:             void getdata();             void display(); }; // Defining getdata function body void item :: getdata() {         cout<< "\n\n- Enter I

#3 | C++ | Write a Program to take two numbers from the user and calculate the Addition, Subtraction, Multiplication and Division.

Image
  CompTech  C++ Practical Assignment #practical 3  YouTube Video :-  Question :-  Write a Program to take two numbers from the user and calculate the Addition, Subtraction, Multiplication and Division. Code :- // Write a Program to take two numbers from the user and // calculate the Addition, Substraction, Multiplication and Division #include <iostream> using namespace std; int main() {     // declare varriabels     int a,b;     float res;     // take value from the user     cout<< "Enter a Number :- " ;     cin>>a;     cout<< "Enter a Number :- " ;     cin>>b;     // Calculating Addition, substraction, Multiplication and divison     res = a + b;     // Addition of 5 + 6 = 11     cout<< "\n-> Addition of " <<a<< " + " <<b<< " = " <<res;     res = a - b;     // Addition of 5 - 6 = -1     cout<< "\n-> Substraction of " <<a<< " - &

#2 | C++ | Write a Program to Calculate Area of a circle.

Image
  CompTech  C++ Practical Assignment #practical 2  YouTube Video :-  Question :-  Write a Program to calculate area of a Circle in C++. Code :- // Write a Program to Find Area of a circle // Area = pi(3.14) * r * r // r = Radius of a circle #include <iostream> using namespace std; int main() {     // declare some variables     int r;     float pi= 3.14 , area;     // assign values from user     cout<< "Enter radius of a Circle :- " ;     cin>>r;     // calculate the area of circle     area = ( float ) pi * r * r;     // print area of a circle     cout<< "\n-> Area of a Circle = " <<area; } Description :- - First we have to declare three variables to store the data.. 1. integer r for storing the value of radius 2. float pi for pi(3.17) 3. float area to store the result after calculation - After declaring variables we have to assign the value to the Integer variable 'r'           from user. - Then we have to calculat