0% found this document useful (0 votes)
165 views5 pages

C++ Program To Perform Addition Subtraction Multiplication Division and Modular

The document contains the name, roll number, class, semester, and university of the student Shafique Younas. It then includes two C++ programs to perform basic mathematical operations like addition, subtraction, multiplication, division, and modulus. The first program performs the operations on two numbers input by the user. The second program allows the user to input two numbers and select the operation to perform from a menu of options. Both programs demonstrate the use of basic C++ syntax and output the results of the calculations.

Uploaded by

Shafiqueyounas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
165 views5 pages

C++ Program To Perform Addition Subtraction Multiplication Division and Modular

The document contains the name, roll number, class, semester, and university of the student Shafique Younas. It then includes two C++ programs to perform basic mathematical operations like addition, subtraction, multiplication, division, and modulus. The first program performs the operations on two numbers input by the user. The second program allows the user to input two numbers and select the operation to perform from a menu of options. Both programs demonstrate the use of basic C++ syntax and output the results of the calculations.

Uploaded by

Shafiqueyounas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Assignment no 1

NAME: SHAFIQUE YOUNAS

ROLL NO: 1655

CLASS: BS TECH ELECTRICAL (MORNING)

SEMESTER : 2ND

SUPERIOR UNIVERSITY LAHORE

C++ Program to Perform Addition Subtraction Multiplication Division


and Modular

#include "stdafx.h"
#include <iostream>
#include<conio.h>
using namespace std;

Void main()
{
int a, b, res;
cout << "Enter First number :";
cin >> a;
cout << "Enter Second number :";
cin >> b;
res = a + b;
cout << "\nAddition = " << res;
res = a - b;
cout << "\nSubtraction = " << res;
res = a*b;
cout << "\nMultiplication = " << res;
res = a / b;
cout << "\nDivision = " << res;
res = a % b;
cout << "\nModular = " << res;
getch();
}

Output:

Enter First number: 4


Enter Second number: 3
Addition = 7
Subtraction = 1
Multiplication = 12
Division = 1
Modular = 1

#include "stdafx.h"
# include <iostream>
#include<conio.h>
using namespace std;

void main()
{

int a, b;
char ch;
cout << "Enter first Number :";
cin >> a;
cout << "Enter second Number :";
cin >> b;
cout << "Enter operator (+, -, *, /, %) :";
cin >> ch;
if (ch == '+')
cout << "Result = " << a + b;
else if (ch == '-')
cout << "Result = " << a - b;
else if (ch == '*')
cout << "Result = " << a*b;
else if (ch == '/')
cout << "Result = " << a / b;
else if (ch == '%')
cout << "Result = " << a % b;
else
cout << "Wrong Operator!!!";
getch();
}
Output:
Enter first Number: 5
Enter second Number: 3
Enter operator (+, -, *, /, %): +
Result = 8

C++ Program to Perform Addition Subtraction Multiplication Division


and Modular

#include "stdafx.h"
#include <iostream>
#include<conio.h>
using namespace std;

Void main()
{
int a, b, res;
cout << "Enter First number :";
cin >> a;
cout << "Enter Second number :";
cin >> b;
res = a + b;
cout << "\nAddition = " << res;
res = a - b;
cout << "\nSubtraction = " << res;
res = a*b;
cout << "\nMultiplication = " << res;
res = a / b;
cout << "\nDivision = " << res;
res = a % b;
cout << "\nModular = " << res;
getch();
}

Output:

Enter First number: 4


Enter Second number: 3
Addition = 7
Subtraction = 1
Multiplication = 12
Division = 1
Modular = 1

#include "stdafx.h"
# include <iostream>
#include<conio.h>
using namespace std;

void main()
{

int a, b;
char ch;
cout << "Enter first Number :";
cin >> a;
cout << "Enter second Number :";
cin >> b;
cout << "Enter operator (+, -, *, /, %) :";
cin >> ch;
if (ch == '+')
cout << "Result = " << a + b;
else if (ch == '-')
cout << "Result = " << a - b;
else if (ch == '*')
cout << "Result = " << a*b;
else if (ch == '/')
cout << "Result = " << a / b;
else if (ch == '%')
cout << "Result = " << a % b;
else
cout << "Wrong Operator!!!";
getch();
}

Output:
Enter first Number: 5
Enter second Number: 3
Enter operator (+, -, *, /, %): +
Result = 8

You might also like