0% found this document useful (0 votes)
13 views2 pages

Calculator Code

Uploaded by

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

Calculator Code

Uploaded by

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

def add(num1 , num2):

return num1 + num2


def subtract(num1 , num2):
return num1 - num2
def multiply(num1 , num2):
return num1 * num2
def divide(num1 , num2):
return num1 / num2
print("What do you want to do with the digits ? \n1.Add\n2.Subtract\n3.Multiply\
n4.Divide")
operation = int(input("Enter the operation : 1, 2, 3, 4 : "))
num1 =int(input("Enter the fisrt digit: "))
num2 = int(input("Enter the second digit: "))
if (operation ==1):
print(num1 ,"+",num2 , "=" ,add(num1,num2))
elif(operation ==2):
print(num1 ,"-",num2 , "=" ,subtract(num1,num2))
elif(operation ==3):
print(num1 ,"*",num2 , "=", multiply(num1,num2))
elif(operation ==4):
print(num1 ,"/",num2 , "=" ,divide(num1,num2))
else:
print("Invalid Syntax")

c++ code
#include <iostream>
using namespace std;
struct employee
{
char name[50];
int age;
float salary;
};
int main()
{
employee e1;
cout<<"Enter full name: ";
cin.get(e1.name , 50);
cout<<"Enter age ";
cin>>e1.age;
cout<<"Enter Salary: ";
cin>> e1.salary;
cout<<"\nDisplaying Information."<<endl;
cout<<"name:"<<e1.name<<endl;
cout<<"Age: "<<e1.age<<endl;
cout<<"Salary"<<e1.salary;
return 0;
}
friend
#include<iostream>
using namespace std;
class ClassB;
class ClassC;
class ClassA{
private:
int a;
public:
void ipa()
{
a = 5;
}
friend int subtract(ClassA ,ClassB,ClassC);
}A;
class ClassB{
private:
int b;
public:
void ipb()
{
b = 10;
}
friend int subtract(ClassA ,ClassB,ClassC);
}B;
class ClassC{
private:
int c;
public:
void ipc()
{
c = 15;
}
friend int subtract(ClassA ,ClassB,ClassC);
}C;
int subtract(ClassA objectA ,ClassB objectB,ClassC objectC){
int s;
s=objectA.a - objectB.b - objectC.c;
return(s);
}
int main(){
A.ipa(); B.ipb(); C.ipc();
cout<<"Subtraction : "<<subtract(A,B,C);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy