kindly convert into c++

#include <iostream.h>
#include <conio.h>

void main()
{
clrscr();
int x = 10;
int y = 2;
int sum, difference, product, quotient;
sum = x + y;
difference = x - y;
product = x * y;
quotient = x / y;
cout << "The sum of " << x << " & " << y << " is " << sum << "." << endl;
cout << "The difference of " << x << " & " << "y << is " << difference << "." << endl;
cout << "The product of " << x << " & " << y << " is " << product << "." << endl;
cout << "The quotient of " << x << " & " << y << " is " << quotient << "." << endl;
getch();
}
It is C++.
Just get rid of conio.h (and clrscr and getch).
Change <iostream.h> to <iostream>.
And change
void main
to
int main.
Last edited on
What he said, in action:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream> //fixed
//#include <conio.h> removed

int main() //fixed
{
system("cls"); //clrscr();  //a windows specific alternative.  unix is word clear instead of cls.
//you can also just cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
int x = 10;
int y = 2;
int sum, difference, product, quotient;
//alternative:  double quotient2;
sum = x + y;
difference = x - y;
product = x * y;
quotient = x / y;
//alternative quotient2 = (double)x/y;  to get a decimal quotient like 10.75
cout << "The sum of " << x << " & " << y << " is " << sum << "." << endl;
cout << "The difference of " << x << " & " << "y << is " << difference << "." << endl;
cout << "The product of " << x << " & " << y << " is " << product << "." << endl;
cout << "The quotient of " << x << " & " << y << " is " << quotient << "." << endl;
//put a cin>>  statement here if you require the program to have the user type something before ending. 
}
Last edited on
Topic archived. No new replies allowed.