Write a program to display the following output using a single cout statement. Math = 90 Physics =70 Chemistry = 69
Here's a program in C++ that displays the required output using a single cout statement:
#include <iostream>
using namespace std;
using namespace std;
int main() {
cout << "Math = 90\nPhysics = 70\nChemistry = 69\n";
return 0;
}
Output:
Math = 90
Physics = 70
Chemistry = 69
Physics = 70
Chemistry = 69
Explanation:
- The program uses the cout statement to display the output on the screen.
- The \n characters in the statement represent new lines, which separate each subject and its score.
Here's a program in C++ that displays the required output using a multiple cout statement:
#include <iostream>
using namespace std;
using namespace std;
int main() {
cout << "Math = 90\n";
cout << "Physics = 70\n";
cout << "Chemistry = 69\n";
return 0;
}
Output:
Math = 90
Physics = 70
Chemistry = 69
Physics = 70
Chemistry = 69
Here's a program in C++ that displays the required output using a multiple cout statement and endl:
#include <iostream>
using namespace std;
using namespace std;
int main() {
cout << "Math = 90"<<endl;
cout << "Physics = 70"<<endl;
cout << "Chemistry = 69"<<endl;
return 0;
}
Output:
Math = 90
Physics = 70
Chemistry = 69
Physics = 70
Chemistry = 69
Comments
Post a Comment
If you have any doubts, please let me know