2-) Write a program to display the following output using a single cout statement.
Subject Marks
Mathematics 90
Computer 77
Chemistry 69
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int sub1,sub2,sub3;
cout<<"Enter Mathematics marks = ";
cin>>sub1;
cout<<"Enter Computer marks = ";
cin>>sub2;
cout<<"Enter Chemistry marks = ";
cin>>sub3;
cout<<"\nSubject\t\t\tMarks\n";
cout<<"\nMathematics\t\t"<<sub1;
cout<<"\nComputer\t\t"<<sub2;
cout<<"\nChemistry\t\t"<<sub3;
getch();
}
Subject Marks
Computer 77
Chemistry 69
Solution:-
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int sub1,sub2,sub3;
cout<<"Enter Mathematics marks = ";
cin>>sub1;
cout<<"Enter Computer marks = ";
cin>>sub2;
cout<<"Enter Chemistry marks = ";
cin>>sub3;
cout<<"\nSubject\t\t\tMarks\n";
cout<<"\nMathematics\t\t"<<sub1;
cout<<"\nComputer\t\t"<<sub2;
cout<<"\nChemistry\t\t"<<sub3;
getch();
}
2 Questions:
this is rong type of code
the code is wrong.
Post a Comment