Bself-1655.docx

  • Uploaded by: Shafiqueyounas
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Bself-1655.docx as PDF for free.

More details

  • Words: 558
  • Pages: 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 #include 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 #include 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 #include 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 #include 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

More Documents from "Shafiqueyounas"

Bself-1655.docx
April 2020 2