HOW TO WRITE A PROGRAM THAT DISPLAYS YOUR NAME INSIDE A BOX ON THE CONSOLE SCREEN?
Dry run the following code and show the output in the end. Explain each step in your answer
void main()
{
int first, second, temp;
first= 25, second=12, temp=0;
temp = first;
first = second;
second = temp;
cout<< first<<endl;
cout<<second;
return 0;
}
Using a do while loop, write a program that will accept the name of the user and display “the user name” N number of times.
Write a program to ask the user to input a value representing a score on a test. The value entered should be between 0 and 100. Use a IF control structure to output a message containing the letter grade corresponding to the score using the following table.
Score Letter grade
0-40 F
41-55 D
56-70 C
71-85 B
86-100 A
Write a program in C++take two matrix and compute their addition subtraction and multiplication. With output
#include <iostream>
#include <string>
using namespace std;
struct book
{
string title;
string author;
unsigned int year;
};
int main()
{
book bookrec;
cout << “Enter Book Title:”; getline(cin,bookrec.title);
cout << “Enter Book Author:”; getline(cin,bookrec.author);
cout << “Enter Publication Year:”; cin >> bookrec.year;
cout << “The following information has been received…\n”);
cout << “Book Title:” << bookrec.title;
cout << “Book Author:” << bookrec.author;
cout << “Year Published:” << bookrec.year << “\n”;
system(“pause”);
return 0;
}
1) What is the output produced by the following code? Explain the code in detail.
int *p1, *p2;
p1 = new int;
p2 = new int;
*p1 = 10;
*p2 = 20;
cout << *p1 << " " << *p2 << endl;
p1 = p2;
cout << *p1 << " " << *p2 << endl;
*p1 = 30;
cout << *p1 << " " << *p2 << endl;
How would the output change if you were to replace *p1 = 30; with the following? *p2 = 30;
Write a C++ program that prompts a user for three integers- the first denoting a month (1 to 12), the second denoting a day (1 to 31) and the third denoting a year. The output is displayed as "month day, year" string where month represents the name of the month.
For example, if inputs are 12, 15 and 2020 respectively, the output is December 15,
Write a program in C++ that reads text from the keyboard and stores it in a file named “File1.txt”. Also, for each of the specified prototypes given below, write the function definitions.
void copyselc(ifstream& fp, ofstream& fp1):This function reads the contents of the file “File1.txt” and copies those lines from the file that begin with the character „#‟ to the file named “File2.txt”.
void checksize(ifstream& fp1,ifstream& fp2):This function reads two files “File1.txt” and “File2.txt” and counts the number of characters in both the files. If the count of characters in both the files is same, then the function should print the message “Both Files are of the same size” else it should display “Size of the files is not same”.
void dispNumNames(ifstream& fp):Assuming that the file “File2.txt” may also contain numbers (1 to 5), this function will read the contents from the file and display the number names for any numbers encountered.