0% found this document useful (0 votes)
11 views15 pages

OVERLOADING

The document contains code for 5 C++ programs that define structures for different objects: a calculator, printer, music player (pendrive), smart TV, and vehicle. Each structure contains functions that can handle different data types for common operations like addition, subtraction, printing details, playing music, displaying info, and starting the vehicle. The main function demonstrates calling the functions of each structure and printing the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views15 pages

OVERLOADING

The document contains code for 5 C++ programs that define structures for different objects: a calculator, printer, music player (pendrive), smart TV, and vehicle. Each structure contains functions that can handle different data types for common operations like addition, subtraction, printing details, playing music, displaying info, and starting the vehicle. The main function demonstrates calling the functions of each structure and printing the results.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

1)CALCULATOR

#include<stdio.h>

#include<string.h>

struct Calculator

int add(int a,int b)

return a+b;

float add(float x,float y)

return x+y;

float add(int a ,float b)

return a+b;

float add(float a, int b )

return a+b;

}
int sub(int a,int b)

return a-b;

float sub(float a,float b)

return a-b;

float sub(int a,float b)

return a-b;

float sub(float a,int b)

return a-b;

int mul(int a,int b)

return a*b;

}
float mul(float a ,float b)

return a*b;

float mul(int a,float b)

return a*b;

float mul(float a,int b)

return a*b;

int div(int a,int b)

return a*b;

float div(float a ,float b)

return a*b;

}
float div(int a,float b)

return a*b;

float div(float a,int b)

return a*b;

};

int main()

Calculator c1;

int a=10,b=20;

/////////////ADDITIONNN//////////////////////

printf("\n\n^^^^^^Addition values^^^^^^\n");

printf("The addition of datatype int int is :%d",c1.add(a,b));

float x=20.2,y=32.0;

printf("\nThe addition of datatype float float is :%0.2lf",c1.add(x,y));

int e=33;

float f=45.0;
printf("\nThe addition of datatype int float is :%0.2lf",c1.add(e,f));

float kk=90.78;

int o=67;

printf("\nThe addition of datatype float & int is :%0.2lf",c1.add(kk,o));

Calculator c2;

int z=20,v=15;

///////////////////SUBSTRACTIONNN/////////////////

printf("\n\n^^^^^^Substraction values^^^^^^\n");

printf("\nThe susbtraction of datatype int & int is:%d",c2.sub(z,v));

float r=66.00 ,p=36.00;

printf("\nThe substraction of datatype float & float is:%0.2lf",c2.sub(r,p));

int t=12;

float u=27.99;

printf("\nThe substraction of datatype int & float is:%0.2lf",c2.sub(t,u));

float n=55.45;
int l=27;

printf("\nThe substraction of datatype float & int is:%0.2lf",c2.sub(n,l));

Calculator c3;

int q=5,k=6;

/////////////MULTIPLICATION//////////////

printf("\n\n^^^^^^Multiplication values^^^^^^\n");

printf("\nThe Multiplication of datatype int & int is:%d",c3.mul(q,k));

float ee=7.7,h=8.0;

printf("\nThe Multiplication of datatype float & float is:%0.2lf",c3.mul(ee,h));

int aa=7;

float bb=4.2;

printf("\nThe Multiplication of datatype int & float is:%0.2lf",c3.mul(aa,bb));

float ae=3.5;

int be=6;

printf("\nThe Multiplication of datatype float & int is:%0.2lf",c3.mul(ae,be));

Calculator c4;

int qe=5,ke=6;

////////////////DIVISION///////////////////
printf("\n\n^^^^^^Division values^^^^^^\n");

printf("\nThe Division of datatype int & int is:%d",c4.div(qe,ke));

float eq=7.7,qw=8.0;

printf("\nThe Division of datatype float & float is:%0.2lf",c4.div(eq,qw));

int ap=7;

float bp=4.2;

printf("\nThe Division of datatype int & float is:%0.2lf",c4.div(ap,bp));

float aq=3.5;

int bq=6;

printf("\nThe Division of datatype float & int is:%0.2lf",c4.div(aq,bq));

2)PRINTER

#include<stdio.h>

#include<s tring.h>

struct Printer

char* print(char*name)

return name;

}
char print(char a)

return a;

int print(int b)

return b;

};

int main()

Printer p1;

char name[20];

char a;

int b;

printf("\n Enter the Document name: ");

gets(name);

printf("\n Enter the character:");

scanf("%c",&a);

printf("\nEnter Number of copies you want to print:");


scanf("%d",&b);

printf("\nName of document:%s",p1.print(name));

printf("\nEntered character is:%c",p1.print(a));

printf("\nPages Printed:%d",p1.print(b));

3)PENDRIVE

#include<stdio.h>

#include<string.h>

struct MusicPlayer

char* play(char*name)

return name;

char play(char a)

return a;

float play(float b)

return b;

}
int play(int f)

return f;

};

int main()

MusicPlayer m1;

char name[50];

char aux;

float pendrive_type;

int memorycard;

printf("\n Enter the Music player name: ");

gets(name);

printf("\n Enter the aux character:");

scanf("%c",&aux);

printf("\nEnter the pendrive type It's 2.0 or 3.0 :");

scanf("%f",&pendrive_type);

printf("\nEnter the number of songs in memory card:");

scanf("%d",&memorycard);
printf("\nMusic player name:%s",m1.play(name));

printf("\nCharacter of AUX:%c",m1.play(aux));

printf("\nPendrive type :%0.2lf",m1.play(pendrive_type));

printf("\nNumber of songs in memory card:%d",m1.play(memorycard));

4)SMART_TV

#include<stdio.h>

#include<string.h>

struct Smarttv

char* display(char*name)

return name;

char display(char a)

return a;

double display(double b)
{

return b;

int display(int f)

return f;

};

int main()

Smarttv t1;

char name[50];

char a;

double bluetooth;

int HDMI;

printf("\n Enter the Brand name: ");

gets(name);

printf("\n Connection with:\nA)LAPTOP:\nB)BLUETOOTH:\nC)MOBILE:\n:::");

scanf("%c",&a);

printf("\nEnter the bluetooth version:");

scanf("%lf",&bluetooth);
printf("\nEnter the sockets of HDMI:");

scanf("%d",&HDMI);

printf("\nBrand name:%s",t1.display(name));

printf("\nConnetion name:%c",t1.display(a));

printf("\nBluetooth version:%lf",t1.display(bluetooth));

printf("\nHDMI sockets :%d",t1.display(HDMI));

5)VECHILE

#include<stdio.h>

#include<string.h>

struct Vechile

char* start(char*name)

return name;

char start(char a)

return a;
}

double start(double b)

return b;

int start(int f)

return f;

};

int main()

Vechile v1;

char fuel[50];

char a;

double mileage;

int engine;

printf("\n Enter the fuel name: ");

gets(fuel);

printf("\n Start with:\nA)KICK:\nB)SELF START:\nC)KEY:\n:::");

scanf("%c",&a);
printf("\nEnter the mileage:");

scanf("%lf",&mileage);

printf("\nEnter engine no:");

scanf("%d",&engine);

printf("\nFuel Name:%s",v1.start(fuel));

printf("\nStart with:%c",v1.start(a));

printf("\nMileage:%lf",v1.start(mileage));

printf("\nEngine no:%d",v1.start(engine));

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