QUESTION 1
#include<bits/stdc++.h>
using namespace std;
int multiply(int a, int b) {
return a*b;
float multiply(float a, int b) {
return a*b;
double multiply(double a, double b) {
return a*b;
int main() {
cout<<multiply(1,2)<<endl;
cout<<multiply(1.2f,1)<<endl;
cout<<multiply(1.1,2.1)<<endl;
OUTPUT
QUESTION 2
#include<bits/stdc++.h>
using namespace std;
void compare(int a, int b) {
if(a==b)
cout<<"Both are equal"<<endl;
else
cout<<"Both are unequal"<<endl;
}
void compare(string a, string b) {
if(a==b)
cout<<"Both are equal"<<endl;
else
cout<<"Both are unequal"<<endl;
void compare(char a, char b) {
if(a==b)
cout<<"Both are equal"<<endl;
else
cout<<"Both are unequal"<<endl;
int main() {
compare(1,1);
compare(string("abc"),string("acb"));
compare('a','b');
OUTPUT
QUESTION 3
#include<bits/stdc++.h>
using namespace std;
void reverse(int &a) {
int num = a;
int rev=0;
while(num>0) {
rev=rev*10+num%10;
num=num/10;
a = rev;
void reverse(string &a) {
reverse(a.begin(), a.end());
void reverse(float &a) {
string val = to_string(a);
reverse(val.begin(), val.end());
a = stof(val);
int main() {
int int_val = 1;
string str_val = string("abc");
float float_val = 1.11;
reverse(int_val);
reverse(str_val);
reverse(float_val);
cout<<int_val<<endl;
cout<<str_val<<endl;
cout<<float_val<<endl;
OUTPUT
QUESTION 4
#include<bits/stdc++.h>
using namespace std;
struct Book {
char title[50];
char author[50];
float price;
};
int main() {
Book book1={ "Book1", "Author1", 100.99f };
Book book2={ "Book2", "Author2", 200.99f };
Book book3={ "Book3", "Author3", 300.99f };
cout<<book1.title<<" written by "<<book1.author<<" has price of Rs."<<book1.price<<endl;
cout<<book2.title<<" written by "<<book2.author<<" has price of Rs."<<book2.price<<endl;
cout<<book3.title<<" written by "<<book3.author<<" has price of Rs."<<book3.price<<endl;
OUTPUT
QUESTION 5
#include<bits/stdc++.h>
using namespace std;
struct Employee {
int empId;
char name[50];
float salary;
};
void printEmployee(Employee emp) {
cout<<emp.name<<" with employeeId "<<emp.empId<<" has salary of Rs."<<emp.salary<<endl;
int main() {
Employee emp;
cout<<"Enter employeeId:";
cin>>emp.empId;
cout<<"Enter employee name:";
cin>>emp.name;
cout<<"Enter employee salary:";
cin>>emp.salary;
printEmployee(emp);
OUTPUT
QUESTION 6
#include<bits/stdc++.h>
using namespace std;
struct Product {
int productId;
char name[50];
float price;
};
void printProducts(Product arr[], int n) {
for(int i=0;i<n;i++) {
cout<<arr[i].name<<" with productId "<<arr[i].productId<<" has price of
Rs."<<arr[i].price<<endl;
int main() {
int n;
cout<<"Enter n:";
cin>>n;
Product arr[n];
for(int i=0; i<n; i++) {
cout<<"Enter productId for product"<<i+1<<":";
cin>>arr[i].productId;
cout<<"Enter product name"<<i+1<<":";
cin>>arr[i].name;
cout<<"Enter product price"<<i+1<<":";
cin>>arr[i].price;
printProducts(arr, n);
OUTPUT
QUESTION 7
#include<bits/stdc++.h>
using namespace std;
struct Date {
int day;
int month;
int year;
};
struct Person {
char name[50];
Date date;
};
void displayDetails(Person p) {
cout<<p.name<<" was born on "<<p.date.day<<"/"<<p.date.month<<"/"<<p.date.year<<endl;
int main() {
Person p;
cout<<"Enter name:";
cin>>p.name;
cout<<"Enter year of birth(YYYY):";
cin>>p.date.year;
cout<<"Enter month of birth(MM):";
cin>>p.date.month;
cout<<"Enter day of birth(DD):";
cin>>p.date.day;
displayDetails(p);
OUTPUT