There are following two major issues associated with CPP programs:
When a program is terminated, the entire data is lost.
If you have to enter a large number of data, it will take a lot of time to enter them all in the different programs.
Suggest a solution and elaborate the same with the help of suitable examples.
Water is solid if its temperature is 273 Kelvin and below. It is liquid when its temperature is between 273 Kelvin and 373 Kelvin. When it is 373 Kelvin and higher, it becomes gas. Create a program that will ask for the temperature of the water in Kelvin, and display the its phase. Use Boolean operators and If statements.
A certain organization needs to elect its new president. So, they started looking for potential candidates. A candidate must be 30 to 40 years old and must be male in pursuance to its by-laws. Create a program that will ask the gender and age of the candidate applicant and will print if the applicant is accepted or rejected to be an official candidate. Use IF statements.
Create a class called Matrix having the following data members int rows; int cols; int mat[][]. Write a program to implement the following operations (the ones mentioned in comments) on Matrix. The main() function of the above program is as below: int main() { Matrix m1(3,3); // it will initialize rows and cols m1.getdata(); //accept the data in matrix Matrix m2=m1; //copy one matrix contents into another m2.putdata(); // display the contents of matrix Matrix m3; m3.putdata(); }
Write a C++ program to create a new file named “college.txt” to store list of colleges under Punjab university. Read names of 3 colleges (consider input given below) from console and store it in “college.txt”. Further copy contents of “college.txt” in another file “university.txt”. Now open the “university.txt” file and display the following (underlined) characters on console using file manipulation functions.
Input: Lovely Professional University Thapar Institute of Engineering and Technology Dr B R Ambedkar National Institute of Technology
Write a program in C++ to open and read the contents of th . ” of the current e Text1.txt using the file stream class. Close the file and again open to update the contents of given file Text1.txt. Text1.txt : I am enjoying learning OOPS concepts After update Text1.txt: I am enjoying learning OOPS concepts Now learnt C++; Java is my next target
Write a C++ program to create a new file named “college.txt” to store list of colleges under Punjab university. Read names of 3 colleges (consider input given below) from console and store it in “college.txt”. Further copy contents of “college.txt” in another file “university.txt”. Now open the “university.txt” file and display the following (underlined) characters on console using file manipulation functions.
Input:
Lovely Professional University
Thapar Institute of Engineering and Technology
Dr B R Ambedkar National Institute of Technology
Write a program to overload binary – (minus) operator for Number class using friend function. Number class have
two data members as num1 and num2.
Write a program that demonstrate the use of constructor with default
arguments for the following problem. Define a class Person with data member as name
and age. Create three objects with no argument, one argument name and two argument
name and age. You are not allowed to create more than one constructor.
Create a class Number with a pointer as a data data member of integer type. Write user defined copy constructor to
the class and implement the deep copy for the Number class objects. So when a new object is created from an
old object of the Number class, pointer data member can point different memory block.