C++ Answers

Questions answered by Experts: 9 913

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Q. Write a class Bank that has the following data members.
Account Holder name (ah_name[])
Account number (ac_number)
Must unique, system generates automatically, and must starting from 100 (Hints: Use another static variable and assign that variable to ac_number)

Balance in the account (ac_balance)



The class has the following member functions.

A constructor to initialize the data members.
Input() to takes name from the user.
Deposit(parameter) to deposits balance in the account.
Must accept parameter (The amount to deposit).
Withdraw(parameter) to withdraws balance after checking.
Must accept parameter (The amount to withdraw).
Display() to show the name, account number, and balance.
Q1. Briefly Explain the following terms:
Classes and objects.
Constructor and its 3 types.
Static Data Members and Static Member Functions.

Study codes given below and add your own codes so that the program is able to:

- count and display the number of vowels exist in the array

- replace all those alphabets after ‘q’ with the symbol ‘*’ 

- display the latest contents of the array


#include<iostream>

using namespace std;


int main()

{

  char myArray[] = {'i', 'n', 't', 'e', 'r', 'n', 'a', 't', 'i','o', 'n', 'a', 'l'};


  //add your codes here

    

  cout<<endl;

  system("pause");

  return 0;

}



1.Write a C++ program that accepts two 4X4 matrices, and calculates:

A.Sum of the matrices

B.Product of the matrices

      Define your functions to do the tasks. 



3.Write a C++ program that accepts sentence from the user, and counts total number of vowel or consonant, and displays the vowel and consonant sentence.

4.Write a C++ program that works exactly like strcat built-in function. It accepts two strings then it concatenates the second string to the first string. Define your function.

5.Write a C++ program that works exactly like strcnmp built-in function. It accepts two strings then it compares the two strings alphabetically considering number of characters to be compared, which is specified by the user. Define your function.


   Write a code to return the following structure from function:

Structure name is Patientand haveTHE following members.

                  Name, cnic, sugar_level.


Create a class named MusicalComposition that contains fields for title, composer, and year written. Include a constructor that requires all three values and an appropriate display function. The child class NationalAnthem contains an additional field that holds the name of the anthem’s nation. The child class constructor requires a value for this additional field. The child class also contains a display function. Write a main()function that instantiates objects of each class and demonstrates that the functions work correctly. Save the file as Compositions.cpp.

Write a funtion using C++ statements called getTotalPraduction() which takes two integer values (value1,value2) and returns the total value


write a c++ program to create a class called date that has separate member data for day month year one constructor should initialize 

this data to 0 and another should initialize it to fixed values .another member function should display it The final member function 

should compare two objects of type date passed as arguments. A main() program should create two initialized date objects(among these one 

should contain today's date and another one should contain your date of birth) and one that isn’t initialized. Then it should compare 

the two initialized values together, leaving the result in the third date variable. Finally it should display the value of this 

third variable. Make appropriate member functions const. 


write a c++ program to create a class called date that has separate member data for day month year one constructor should initialize 

this data to 0 and another should initialize it to fixed values .another member function should display it The final member function 

should compare two objects of type date passed as arguments. A main() program should create two initialized date objects(among these one 

should contain today's date and another one should contain your date of birth) and one that isn’t initialized. Then it should compare 

the two initialized values together, leaving the result in the third date variable. Finally it should display the value of this 

third variable. Make appropriate member functions const. 


LATEST TUTORIALS
APPROVED BY CLIENTS