Professional Documents
Culture Documents
C++ Elab Ultra Merged PDF
C++ Elab Ultra Merged PDF
Problem Description:
Dhoni's daughter Ziva is a hyperactive child, so she used to ask a lot of questions to Dhoni while playing with him.
One fine evening Dhoni and Ziva were playing in Chepak Stadium in Chennai, at that time Ziva looking at the Moon
in the sky asked Dhoni what is the gravity in the moon?
Ziva didn't get satisfied with that then she asked what will be my weight on the moon?
Can you help Dhoni to answer the question by creating a logic that calculates the weight of the person on the
moon so that Ziva will be happy knowing her weight?
Constraints:
1<weightinearth<150
Input Format:
Only line of input has a single Integer representing the weight of the person In earth.
Output Format:
In the only line of output print the weight of the person in moon.
Code:
#include <iostream>
#include <iomanip>
int main()
int weightinearth;
float weightinmoon;
cin>>weightinearth;
weightinmoon=weightinearth*(16.6/100);
cout<<weightinmoon;
return 0;
0 0
0 0
2.Problem Description:
During the IPL Match between CSK and MI, as a part of IPL contest the question was asked to the fans.
Who are all giving the correct answer to that question will get the free VIP box ticket for the Final for which CSK
have already qualified
The question is convert given integer number to octal and hexadecimal number respectively.
Can you help him answer the question so that he can watch CSK play the final from VIP box?
Constraints:
1<iplno< 10000
Input Format:
Only line of input has single integer number that need to be converted.
Output Format:
In the First line of output print the octal number equivalent to the input value.
In the Second line of output print the hexadecimal number equivalent to the input value.
Code:
#include <iostream>
int main()
int iplno;
cin>>iplno;
cout.setf(ios::oct);
cout<<oct<<iplno<<"\n";
cout.setf(ios::hex);
cout<<hex<<iplno;
return 0;
0 0
0 0
3.Problem Description:
Akash the die heart fan of AR Rahman went to the live concert happened in Bangalore with his family members.
The event management firm responsible for the event arranged the seats for the audience in descending order of
maximum number of tickets booked for single family.
As per the seating arrangement family with the highest number of people are allotted the seats in the front rows
and the family with the lowest number of people are allotted the seats in the last row.
For the convenience of the seating arrangement volunteers to know how many seat need to be positioned in each
row the event management firm have planned to develop the software which displays the exact seat layout if the
total number of rows is provided.
Constraints:
1 ≤ nooffamily members ≤ 20
Input Format:
Only line of input has single integer representing the total number of rows for the concert.
Output Format:
Print the seating arrangement layout based on the number of rows provided.
Code:
#include <iostream>
int main()
{0
int nooffamilymembers,i;
cin>>nooffamilymembers;
for(i=nooffamilymembers;i>=1;i--)
cout<<i<<" ";
cout<<endl;
0 0
return 0;
0 0
4. Problem Description:
Theatre staffs insisted the audience to sit in odd row if the seat number is odd and in even row if the seat number
is even.
But the instruction is very confusing for Laaysa and her friends.
So help them with the seating layout so that they can sit in correct seats.
Constraints:
4 ≤N≤ 20
Input Format:
Only line of input has single integer value representing the number of rows in the theatre.
Output Format:
Code:
#include <iostream>
int main()
int N,c;
cin>>N;
for(int i=1;i<=N;i++)
if(i%2==0)
c=2;
else
c=1;
for(int j=1;j<=i;j++)
cout<<c<<" ";
c+=2;
0 0
}
cout<<endl;
return 0;
0 0
5. Problem Description:
Omkar the Professor of a Famous Technical University have decided to give a simple task to his students.
He asked his students to create a programming logic for automatically calculating the amount of energy needed to
heat X amount of water from Y initial temperature to Z final temperature.
But Professor Omkar's Students are Finding it difficult to find the solution to the problem.
Functional Description:
Where,
and
Constraints:
1<M<1000
0<initialtemp<25
0<finaltemp<75
Input Format:
Only Line of Input has three floating point values separated by a space representing M, initialtemp and finaltemp
respectively.
Output Format:
Code:
#include <iostream>
int main()
cin>>M>>initialtemp>>finaltemp;
Q=M*(finaltemp-initialtemp)*4184;
cout<<""<<Q;
0 0
return 0;
0 0
6. Problem Description:
Three brothers want to take a photo with family members. The photographer is capturing the photo from a long
distance.
Some of the family members are standing behind that brothers and those people are not visible to the
photographer.
To get clarity, he asked, "who is the tallest person among those three brothers? But no one responded clearly.
Can you help the photographer in finding the tallest among the three brothers?
Constraint:
60 ≤bro1 ≤ 80
60 ≤ bro2 ≤ 80
60 ≤ bro3 ≤ 80
Input Format:
The only line of Input has three numbers bro1,bro2 and bro3 of type Integers separated by a space which
represents the height of three brothers.
Output Format:
Code:
#include <iostream>
#include<iomanip>
int main()
int bro1,bro2,bro3;
cin>>bro1>>bro2>>bro3;
cout<<bro1;
cout<<bro2;
else
cout<<bro3;
return 0;
0 0
}
0 0
7. Problem Description:
Guru says a random numbers to Siva and he needs to convert the numbers to words.
Since Guru is very fast in telling the numbers, Siva cant able to cope up with his friend in converting it to words.
Can you help Siva in converting the particular number to words by creating a simple programming logic.
Constraints:
1<N<1000
Input Format:
The Only line of input has a single Integer representing the number said by Guru.
Output Format:
Code:
#include <iostream>
int main()
cin>>n;
while(n>0)
r=n%10;
sum=sum*10+r;
n=n/10;
n=sum;
while(n>0)
r=n%10;
switch(r)
0 0
case 1:
cout<<"One ";
break;
case 2:
cout<<"Two ";
break;
case 3:
cout<<"Three ";
break;
case 4:
cout<<"Four ";
break;
case 5:
cout<<"Five ";
break;
case 6:
cout<<"Six ";
break;
case 7:
cout<<"Seven ";
break;
case 8:
cout<<"Eight ";
break;
case 9:
cout<<"Nine ";
break;
case 10:
cout<<"Ten ";
break;
0 0
n=n/10;
0 0
8. Problem Description:
After completing some serious investigation, Arif and Simon are now chilling themselves in the Ooty hills. Very
soon Simon became bored. Simon lived entirely for his profession. We know he is a workaholic. So Simon wants to
stop his vacation and get back to work. But after a tiresome season, Arif is in no mood to return soon.
So to keep Simon engaged, he decided to give to pull the idea of restarting the admissions of the academy they
started last year for the new academic year-2021.
Now Simon and Arif have decided to start the new admissions to the academy. As a part of the first round, the
applied students had to solve a small puzzle. The puzzle was very simple. Arif has arranged N dummy statues in
some order of height Hi.
Now Simon have made up the question asking to the applicants that In how many ways they can choose the
sequence of consecutive dummy statues, where the tallest and shortest statue in the selected sequence is the
same.
If you would like to get admission into his academy, your first step is to solve the question. Give it a try :)
Constraints:
1<t< 10.
1≤n≤ 100000
1≤|h|≤ 10^9
Input Formant:
First line of the input will contain t denoting the number of test-cases.
For every test case, first line will contain n. Next line will contain n space separated integers denoting h.
Output Format:
Code:
#include <iostream>
int main()
int t,n,h,i,l=1,count;
cin>>t;
while(t--)
l=1;
0 0
count=0;
cin>>n;
for(i=1;i<=n;i++)
cin>>h;
if(h==l)
count+=2;
if(h>l)
l=h;
count++;
cout<<count<<endl;
return 0;
0 0
9. Problem Description:
Every day students count is varying in all the hostels due to continuous holidays.
Since ramesh is in charge of the cooking team. He had trouble with calculating the quantity of food that needs to
be prepared because of the varying student count.
Even if a small quantity of food is prepared by the cooking team, it should be divided equally among the number of
Mess. Ramesh needs an automated software to identify the amount of food available (in number of packets) and
Mess count.
Can you help him to divide the food equally and also calculating the remaining quantity of food that will be
available after sharing the food equally ?
Constraints:
1≤ alvantoffood ≤10000
1<messcnt<20
Input Format:
Only line of input has two integers (alvantoffood, messcnt) separated by space representing the available number
of food packets and the available number of messes respectively
Output Format:
In the only line of output print two values separated by a space representing the number of food packets that are
equally shared by "n" number of messes and the remaining number of food packets available.
Code:
#include <iostream>
int main()
int alvqntoffood,messcnt,dividedqnt,remfood;
cin>>alvqntoffood>>messcnt;
dividedqnt=alvqntoffood/messcnt;
remfood=alvqntoffood % messcnt;
cout<<dividedqnt<<" "<<remfood;
return 0;
0 0
0 0
10. Question description:
To celebrate the Reunion of 96 Batch of the Famous School the Ram and Jannu the organizers of the event decided
to liters of Fruit Drinks.
However, an unexpected difficulty occurred in the shop: it turned out that Fruit Drinks is sold in bottles 0.5, 1 and 2
li volume.
At that, there are exactly a bottles 0.5 in volume, bone-liter bottles and c of two-liter ones.
The organizers have enough money to buy any amount of Fruit Drinks.
What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for
the of Fruit Drinks among the Friends.
Your task is to count the number of all the possible ways to buy exactly n liters of Fruit Drinks and persuade the
organ this number is too large.
All the bottles of Fruit Drinks are considered indistinguishable, i.e. two variants of buying are different from each
othe they differ in the number of bottles of at least one kind.
Constraints:
1≤n≤ 10000
0≤ a, b, c < 5000
Input Format:
Output Format:
Code:
#include <bits/stdc++.h>
class Drinks{
int n,a,b,c,t,ans=0;
public:void Shop(){
cin>>n>>a>>b>>c;
void display(){
for(int i=0;i<=b;i++)
for(int j=0;j<=c;j++)
0 0
if(2*(n-i-j*2)>=0&&2*(n-i-j*2)<=a)
ans++;
cout<<ans;
};
int main(){
Drinks Buy;
Buy.Shop();
Buy.display();
return 0;
0 0
11.Problem Description:
Tamilnadu Educational Minister has ordered the Director of Higher education to make the Libraries in Government
schools advanced.
So they are planning to create a software which keeps track of the books availability and respond to students
request for books.
Functional Description:
Input values need to be passed to the Parameterized constructor and to output need to be printed by accessing i t.
Constraints:
Input Format:
First and Second Line of Input has 3 values of type integer, String and Integer separated by a space representing
Roll Number,
Output Format:
Code:
#include <iostream>
#include <string>
class library_A
public:
string name;
int roll,bookcode;
void readinput()
cin>>roll>>name>>bookcode;
0 0
{
r=roll;
n=name;
code=bookcode;
void display()
};
int main()
library_A lib1,lib2;
lib1.readinput();
lib2.readinput();
lib1.display();
lib2.display();
return 0;
0 0
12. Problem Description:
Bhagavan the Government school teacher from Tamil Nadu is so involved with his students development which in
turn even forced the Tamilnadu Educational Department to cancel his transfer from his old school on the request
of his students.
He is such an inspirational teacher. Now he has been assigned the new set of students from other schools to train
them.
So before starting the training he wants to collect the personal details from the new student for maintaining the
record in his school.
Can you help him to automate his task of collecting student details?
Functional Description:
Bhagavan wanted to display his following details along with every student record.
Constraints:
Input Format:
Only line of input has four values of tyle String, Integer, Float and Float separated by as space representing
Name,Roll Number, Height and Weight of students respectively.
Output Format:
In First Line of output print the details collected from the student.
Code:
#include <iostream>
#include <string>
class student
public:
string name;
int roll;
0 0
float height,weight;
student(){name="Bhagavan";roll=1593;height=172.5;weight=60.4;}
void readinput()
cin>>name;
cin>>roll;
cin>>height;
cin>>weight;
void displaydata()
};
int main(){
student s1,s2;
s1.readinput();
s1.displaydata();
s2.displaydata();
return 0;
0 0
13. Problem Description:
Fahad is the owner of one of the biggest Super Market in the City.
Since the day Fahad has taken charge of the Super Market from his father he is trying hard to save unproductive
time of their workers.
Workers of his super market is spending lots of time in calculating the prices of items purchased by the customers
so the long people queue keeps forming.
So now is planned to create a software which gets the number of items, Item code and Price as from the staff and
provide them the largest price among the items purchased and the sum of prices of all the items.
Since Fahad is not aware of the technical stuffs of implementation, can you help him with the programming logic
for the software?
Constraints:
1<no_items<10
100<itemcode<500
1<itprice ≤ 1000
Input Format:
The first line of the input contain a single value of type integer representing no. of items N.
The next N lines contain two values of type integer and float separated by a space representing Item code and
Item Price respectively.
Output Format:
Print the largest price among all items, the total price of all items, item code and price of all the items in the
expected format.
Code:
#include <iostream>
class ITEM
public:
int n;
float large=0,summ=0;
float arr[100],code[100];
n=b;
0 0
for(int i=0;i<n;i++)
cin>>code[i]>>arr[i];
void largest(){
for(int i=0;i<n;i++)
if (arr[i]>=large)
large=arr[i];
void sum(){
for(int i=0;i<n;i++)
summ+=arr[i];
void displayitems(){
cout<<"Largest Price="<<large<<endl;
cout<<"Sum of Prices="<<summ<<endl;
for(int i=0;i<n;i++)
};
int main()
ITEM order;
int b;
cin>>b;
order.getdata(b);
order.largest();
order.sum();
order.displayitems(); return 0; }
0 0
14. Problem Description:
Abi and Jannu are off to the wedding of a close relative. This time they have to travel without their guardians. Abi
got very interested in the arrangement of seats
Berth Number
Compartment
14 8
9 16
17 24
... and so on
11B,
308,
4LB,
5MB,
6UB,
75L,
3U8
1LB
SMB
4LB
75L
and the pattern is repeated for every set of 8 berths. Abi and Jannu are playing this game of finding the train
partner of each berth. Can you write a program to do the same?
0 0
Constraints:
1 ≤ N≤ 500
Input Format:
First line of input has a single integer T representing the number of Testcases
Next T Line of input contain a single integer N, the berth number whose neighbor is to be found out
Output Format:
For each testcase T in a separate line output the berth number of the neighbor of the corresponding seat.
Code:
#include <iostream>
class partner
public:
void findpartner()
int t;cin>>t;
while(t--){
int n;
cin>>n;
switch(n%8){
case 0: cout<<(n-1)<<"SL"<<endl;
break;
case 1: cout<<(n+3)<<"LB"<<endl;
break;
case 2: cout<<(n+3)<<"MB"<<endl;
break;
case 3: cout<<(n+3)<<"UB"<<endl;
break;
case 4: cout<<(n-3)<<"LB"<<endl;
break;
case 5: cout<<(n-3)<<"MB"<<endl;
0 0
break;
case 6: cout<<(n-3)<<"UB"<<endl;
break;
case 7: cout<<(n+1)<<"SU"<<endl;
break;
}}}};
int main() {
partner travel;
travel.findpartner();
return 0;
0 0
15.Question description:
Indian Army have decided to create a group of innovative developments for Strengthen Cyber Security of Indian
Army consisting from 5 to 7 people and hire new employees for it.
Now the Scrutinising Committee has to evaluate each possible group composition and select one of them.
Can you help Indian army people in counting the number of variants of group composition to evaluate.
Constraints:
7<n<800
Input Format:
The only line of the input contains one integer n representing the number of potential employees that sent
resumes.
Output Format:
Output one Integer representing the number of different varlants of group composition.
Code:
#include <iostream>
class IndianArmy
public:intResumesofCamdidates(){
long long n;
cin>>n;
cout<<k+k*(n-5)/6+k*(n-5)*(n-6)/42;
return 1;
};
int main(){
IndianArmyGroupingofResumes;
GroupingofResumes.ResumesofCamdidates();
return 0;
0 0
16.Question description:
Zaheer needs a fence around his farm, but he is too lazy to build it himself.
The robot builds the fence along a single path, but it can only make fence corners at a single angle a.
Constraints:
0</<200
0<a<180
Input Format:
Each of the following lines contains a single Integer a representing the angle the robot can make corners at
measured in degrees.
Output Format:
For each test, output on a single line "YES" (without quotes), if the robot can build a fence Emuskald wants, and
"NO" (without quotes), if I is impossible.
Code:
#include <bits/stdc++.h>
class Farm
{ public:void Fence(){
int t,a;
cin>>t;
while(t--)
cin>>a;
if(360%(180-a)==0)
cout<<"YES"<<endl;
else{
0 0
cout<<"NO"<<endl;
};
};
int main()
{ Farm robot;
robot.Fence();
return 0;
0 0
17.Problem Description:
Tamilnadu land registration authority is panning to keep track of the native addresses and total area of the flats
people have across the state.
Since the total population and area need to be monitored is huge. Government is looking for the software which
does this task.
Can you help them with proper programming logic for implementing the same?
Constraints:
1≤ hno<500
1< no room<10
1≤ length < 50
1≤ height < 50
Input Format:
The first line of the input contain a single string denoting the house name.
The second line of the input contain three values of type Integer String and String separated by a space
representing house number, city and state respectively.
The third line of the input has a single Integer representing the number of rooms.
The subsequent lines of input must have length, breadth and height of each room
Output Format:
Code:
#include <bits/stdc++.h>
#include <string.h>
class house
public:
string housename,cty,state;
int hno,t,length,breadth,height,length1,breadth1,height1,length2,breadth2,height2;
void input();
void display();
0 0
};
void house::input()
cin>>housename;
cin>>hno>>cty>>state;
cin>>t;
cin>>length>>breadth>>height;
cin>>length1>>breadth1>>height1;
if(t==3)
cin>>length2>>breadth2>>height2;
void house::display()
cout<<"Length="<<length<<"\nBreadth="<<breadth<<"\nHeight="<<height<<endl;
cout<<"Length="<<length1<<"\nBreadth="<<breadth1<<"\nHeight="<<height1<<endl;
if(t==3)
cout<<"Length="<<length2<<"\nBreadth="<<breadth2<<"\nHeight="<<height2<<endl;
int main()
house s;
s.input();
s.display(); }
0 0
18. Problem Description:
Store Keeper of Super market is finding it difficult to keep track of the stocks in the shop.
So he wants a automated script which pick the total number of consumed items from each category and calculate
the remaining stock and print those details so that store keeper can order for those items.
Can you help them by developing the programming logic for satisfying their needs?
Function Description:
Constraints:
2000<side<7000
1≤ totalavi< 1500
1≤ consumed ≤1000
Input Format:
First Line of Input has a single value of type Integer representing item ID.
Second Line of Input has a single value of type integer representing Total Available Count of an Item
Third Line of Input has a single value of type Integer representing Total Consumed Count of an Item.
Output Format:
Code:
#include <iostream>
class Store{
public:
cout<<id<<endl;
cout<<totalavl-consumed<<endl;
};
int main()
0 0
{
Store purchase;
int id,totalavl,consumed;
cin>>id>>totalavl>>consumed;
purchase.itemcount(id);
purchase.itemcount(totalavl,consumed);
return 0;
0 0
19.Problem Description:
Janani the officer in City union bank is responsible for creating new accounts to its customers.
After one month she has to submit the account statement of the customers she has opened accounts to the circle
office.
Can you help her with a programming logic which does the task?
Function Description:
Use the concept of constructor overloading to print the initial balance and the balance status of the account after a
month which can be elther POSITIVE NEGATIVE or Zero.
Constraints:
0.00<balance<100000.00
Input Format:
Only line of input has a single value of type float representing the current balance of the account holder.
Output Format:
In the second line of output print as "Has a Positive Balance" or "Has a Negative Balance" of "Has a Zero Balance"
based on the condition.
Code:
#include <iostream>
class AccBalance{
public:
AccBalance(){cout<<"Zero Balance"<<endl;}
AccBalance(int balance){
if(balance<0)
else if(balance==0)
else
};
0 0
int main()
AccBalancedefltBal;
int balance;
cin>>balance;
AccBalancecurrBal(balance);
return 0;
0 0
20.Problem Description:
Admission for the current Academic year is happening in Most of the Universities across the Country.
Once the Students got admitted they are assigned a unique Registration Number
But during enrollment of the student there is a specific order need to be followed.
So your task is to get the name and registration number of the student from admission in charge and to convert it
to the correct format. Function Description:
Input Format:
First line of Input has a single value of type string representing the name of student 1.
Second line of input has a single value of type Integer representing the id of student 1.
Third line of input has a single value of type Integer representing the id of student 2.
Fourth line of input has a single value of type string representing the name of student 2.
Output Format:
Code:
#include <iostream>
class Student
public:
cout<<name<<" "<<id<<endl;
cout<<name<<" "<<id<<endl;
};
int main()
Student Details;
0 0
string name;
int id;
cin>>name>>id;
Details.Identity(name,id);
cin>>id>>name;
Details.Identity(id,name);
return 0;
0 0
21 Question Description:
Valentina has given a multiset that means a set that can contain multiple equal integers containing 2n Integers.
Determine if you can split it into exactly in pairs consists each element should be in exactly one pair.
So that the sum of the two elements in each pair is odd is divided by 2, the remainder is 1.
Constraints:
The Input consists of multiple test cases. The first line contains an integert the number of test cases. The
description of the test cases follows.
The second line of each test case contains 2n Integers a 1,2,...,a2n the numbers in the set.
Input Format:
1<t< 100
1<s≤100
0<ai< 100
Output Format:
For each test case, print "Yes" if it can be split into exactly pairs so that the sum of the two elements in each pair Is
odd, and "No" otherwise. You can print each letter in any case.
Code:
#include <iostream>
int main()
int t;
cin>>t;
while(t--){
int n,odd=0;
cin>>n;
int z=power(n,odd);
power(n,z,1);
0 0
}
return 0;
int a[2*x];
for(int i=0;i<2*x;i++){
cin>>a[i];
if(a[i]%2==1)
p++;
return p;
if(x==y)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 1;
0 0
22.Problem Description:
Limka Book of Records has an online application facility for the public to register themselves and apply for the
specific achievement which will be taken into account for the entry in to the Limka Book of Records.
In their official website, once the user has registered themselves successfully it has to show the welcome message
"Hi" followed by his/her "First Name".
Similarly the when the user login into his account it has to show "Welcome" followed by "First name and last
name".
Function Description:
Input Format:
First and Second Line of Input has a single value of type string representing the First Name of the User.
Third line of input has a single value of type string representing the last name of the user.
Output Format:
Code:
#include <iostream>
class Welcomemsg{
public:
cout<<"Hi "<<fname<<endl; }
int main(){
Welcomemsgob;
string fname,lname;
cin>>fname;
ob.msg(fname);
cin>>fname>>lname;
ob.msg(fname,lname);
return 0; }
0 0
23.Problem Description:
Elavenil is the working in Survey of India, The National Survey and Mapping Organization of the country under the
Department of Science & Technology, which is the oldest Scientific Department of the Government of INDIA. It was
set up in 1767 and has evolved rich traditions over the years.
Now Elavenil has been assigned the task of Collecting the Area and Density Information of all the states of India
from the local authorities of the respective states and to consolidate in a common portal of Government of INDIA.
Since the task assigned to her is highly complicated in nature she is seeking your help.
Functional Description:
Constraints:
Input Format:
Only Line of input has three values of type string, Integer and integer separated by a space representing Slate
name, Area and Density of
State.
Output Format:
In four lines of output print the details of Country, State, Area and Density respectively in the expected format.
Code:
#include <iostream>
class Country{
public:
Country(){cout<<"Country:INDIA"<<endl;}
cout<<"State:"<<statename<<endl<<"Area:"<<area<<endl<<"Density:"<<density<<endl;
};
int main()
0 0
{
Country country;
char statename[100];
int area,density;
cin>>statename>>area>>density;
Country statesofindia(statename,area,density);
return 0;
0 0
24.Problem Description:
Harsh the HR of a Google HQ in Bangalore is looking for the automated appraisal management system.
The current salary of the employee is fixed and based on the results of the performance monitoring software the
appraisal management system have to revise the salary of the employee.
Functional Description:
Use the Constructor Overloading Concept to develop automated appraisal management system.
Constraints:
30000<sal< 500000
Input Format:
Only line of input has a single value of type integer representing the New salary of the employee.
Output Format:
In the First Line of output print the Old salary of the employee.
In the Second Line of output print the New salary of the employee.
In the Third Line of output print the amount the employee got as hike.
Code:
#include <iostream>
class Appraisal {
int sal;
public:
Appraisal(){sal=30000;cout<<"Old Salary:"<<sal<<endl;}
Appraisal(int sal){cout<<"";}
};
int main() {
Appraisal oldsalary;
Appraisal newsalary(sal);
return 0; }
0 0
25.Question description
Saravanan wants to check his wrist watch time and clock in his car displayed a same time or not?
Constraints
0<hr<23
0<m<60
0<s<60
Input Format:
Output Format:
If time is same print, "Both clocks are showing the same time"
If the Invalid input, print "Invalid time format" and print the desired result in next line.
Code:
#include <iostream>
class Time
int h,m,s;
public:
Time(){cin>>h>>m>>s;}
void check()
if(h>23||m>59||s>59)
};
0 0
if(h==t2.h&&m==t2.m&&s==t2.s)
return true;
else
return false;
int main()
Time t1,t2;
t1.check();
t2.check();
if(t1==t2)
else
return 0;
0 0
26.Question description:
Rahul and Ramesh are military officers. They are travelling to enjoy the vacation by train.
They are planned to play a game during their travel that they are interested in how many ways there are in
scrambling the letters.
One fellow should said the length of the word added by 1 and other fellow should give the number of ways the
letters to be scrambled.
For example, if suppose Rahul gave the length of the word is 6. Then Ramesh should be subtracted that 1 and
calculate for the word's length as 6-1. He have 5 choices for the first letter, once he have chosen the first letter
there are 4 choices for the second letter, and then three choices for the third letter, two for the fourth letter, and
only one choice for the last letter. Hence there are 5(4)(3)(2)[1] =
5=120 choices.
Constraints:
1<n<10
Input Format:
Output Format:
Code:
#include <iostream>
class Scrum{
public:
int n;
Scrum(int h)
n=h;
--n;
0 0
return 1;
void display(){
int res=1;
for(int i=1;i<=n;i++){
res=res*i;
cout<<res;
};
int main()
int n;
cin>>n;
Scrum T(n);
T--;
T.display();
return 0;
0 0
27. Question description
The Wonderking in Wonderland had a great friend called Wondermath a professor in mathematics. The king and
the professor shared everything, they were same age, married same day, have same number of children etc.
To represent this friendship professor Wondermath introduced Amicable numbers, a pair who is friends like him
and king.
Amicable numbers are a pair of numbers with the following property: the sum of all of the proper divisors of the
first number (not including itself) exactly equals the second number while the sum of all of the proper divisors of
the second number (not including itself)
To satisfy his friend Wonderking, professor wants to find many Amicable numbers before the tea time tomorrow.
You must develop a program that declares a number is amicable or not in order to help professor WonderMath.
Constraints
1≤n1,n2<8000
Input Format
Output Format
If amicable numbers, print Friendly Pair. Otherwise print Not a Friendly Pair
Code:
#include <iostream>
class compare{
public:
int first,sum1=0;
compare(int x){
first=x;
void f(){
for(int i=1;i<=first/2;i++)
if(first%i==0)
sum1=sum1+i;
0 0
}
if(first==t2.sum1&&t2.first==sum1)
cout<<"Friendly Pair";
else
};
int main()
int first,second;
cin>>first;
cin>>second;
compare t1(first),t2(second);
t1.f();
t2.f();
t1==t2;
return 0;
0 0
28. Question description
The task is to overload the /operator to divide the fraction with other fraction. You can take the numerator as num
and the denominator as deno.
Constraints
1<num, demo<10^7
Input Format
First line represents the value of numerator and the denominator of first fraction separated by a space
Second line represents the value of numerator and the denominator of second fraction separated by a space
Output Format
Otherwise
Note: If the denominator of any one of the input fractions is zero, then the error message "Error" will be displayed.
Explanation:
Code:
#include <iostream>
class Fraction{
public:
int num,den;
num=n;
den=d;
Fraction res;
0 0
res.num=num*obj.den;
res.den=den*obj.num;
return res;
void display1(){
cout<<num/den;
void display2(){
cout<<num<<"/"<<den;
void display3(){
cout<<"Error";
};
int main()
int a,b,c,d;
cin>>a>>b;
cin>>c>>d;
Fraction ob1(a,b),ob2(c,d);
Fraction ob3=ob1/ob2;
if(ob1.den==0||ob2.den==0)
cout<<"Error";
return 0;
if(ob3.den==1)
ob3.display1();
else
for(int i=2;i<50;i++)
0 0
{
ob3.num=ob3.num/i;
ob3.den=ob3.den/i;
ob3.display2();
return 0;
0 0
29. Question description:
Vijay have taken charge as the Dean of the famous Medical college recently.
After taking over the high profile job he decided to fix all the obstacles faced by the patients visiting the medical
college in the past.
So he planned to create the automated Digital Display system which guides the incoming patients with the doctor
who will take care of them and the bed numbers which are allocated to them.
Input Format:
First line of input has a single value of type string representing the name of the Doctor.
Second line of input has a single value of type string representing the Degree of the Doctor.
Third line of input has a single value of type string representing the name of the patient.
Third line of input has a single value of type integer representing the bed number of the patient.
Constraints:
100<bedno<500
Output Format:
Code:
#include <iostream>
class doctor
public:
string name,degree,pname;
int no;
void getedu()
cin>>name>>degree>>pname;
void getdata()
0 0
cin>>no;
void dispedu()
void dispdata()
cout<<"Bed Number:"<<no<<endl;
};
};
int main()
patient p;
p.getedu();
p.getdata();
p.dispedu();
p.dispdata();
return 0;
0 0
30. Question description:
During her designing process she used to calculate the perimeter of different part of equipment she needs to
design in a 3D environment and update in her design book.
So to avoid confusion she is looking for the automated perimeter measurement tool.
So she will be happy if you can help her with such as tool.
Constraints:
100<length<5000
100<breadth≤5000
Input Format:
Only line of input has a two value of type integer representing length and breadth measurements respectively.
Output format:
Code:
#include <iostream>
class ReceiveMesurement {
public:
int l,b,r;
void perimeter()
cin>>l>>b;
r=l+b+l+b;
cout<<r<<endl; } };
int main()
CalculatePerimeter mt;
mt.perimeter(); return 0; }
0 0
31. Question description:
He will give the students some random numbers and they need to determine if those coordinates can form an
isosceles triangle.
Constraints:
1<side 1≤100
1≤side2<100
1≤side3≤100
Input Format:
Output format:
Code:
#include <iostream>
class triangle
public:
int a,b,c;
void read(){
cin>>a>>b>>c;
void check(){
if(a==b||b==c||a==c){
cout<<"ISOSCELES";
0 0
Constraints:
2000<side<7000
1≤ totalavi< 1500
1≤ consumed ≤1000
Input Format:
First Line of Input has a single value of type Integer representing item ID.
Second Line of Input has a single value of type integer representing Total Available Count of an Item
Third Line of Input has a single value of type Integer representing Total Consumed Count of an Item.
Output Format:
Code:
#include <iostream>
class Store{
public:
cout<<id<<endl;
cout<<totalavl-consumed<<endl;
};
int main()
0 0
{
Store purchase;
int id,totalavl,consumed;
cin>>id>>totalavl>>consumed;
purchase.itemcount(id);
purchase.itemcount(totalavl,consumed);
return 0;
0 0
0 0
19.Problem Description:
Janani the officer in City union bank is responsible for creating new accounts to its customers.
After one month she has to submit the account statement of the customers she has opened accounts to the circle
office.
Can you help her with a programming logic which does the task?
Function Description:
Use the concept of constructor overloading to print the initial balance and the balance status of the account after a
month which can be elther POSITIVE NEGATIVE or Zero.
Constraints:
0.00<balance<100000.00
Input Format:
Only line of input has a single value of type float representing the current balance of the account holder.
Output Format:
In the second line of output print as "Has a Positive Balance" or "Has a Negative Balance" of "Has a Zero Balance"
based on the condition.
Code:
#include <iostream>
class AccBalance{
public:
AccBalance(){cout<<"Zero Balance"<<endl;}
AccBalance(int balance){
if(balance<0)
else if(balance==0)
};
int main()
0 0
{
AccBalancedefltBal;
int balance;
cin>>balance;
AccBalancecurrBal(balance);
return 0;
0 0
20.Problem Description:
Admission for the current Academic year is happening in Most of the Universities across the Country.
Once the Students got admitted they are assigned a unique Registration Number
But during enrollment of the student there is a specific order need to be followed.
So your task is to get the name and registration number of the student from admission in charge and to convert it
to the correct format. Function Description:
Input Format:
First line of Input has a single value of type string representing the name of student 1.
Second line of input has a single value of type Integer representing the id of student 1.
Third line of input has a single value of type Integer representing the id of student 2.
0 0
Fourth line of input has a single value of type string representing the name of student 2.
Output Format:
Print the details of students in the expected format.
Code:
#include <iostream>
class Student
public:
cout<<name<<" "<<id<<endl;
cout<<name<<" "<<id<<endl;
};
int main()
Student Details;
0 0
string name;
int id;
cin>>name>>id;
Details.Identity(name,id);
cin>>id>>name;
Details.Identity(id,name);
return 0;
0 0
0 0
21 Question Description:
Valentina has given a multiset that means a set that can contain multiple equal integers containing 2n Integers.
Determine if you can split it into exactly in pairs consists each element should be in exactly one pair.
So that the sum of the two elements in each pair is odd is divided by 2, the remainder is 1.
Constraints:
The Input consists of multiple test cases. The first line contains an integert the number of test cases. The
description of the test cases follows.
The second line of each test case contains 2n Integers a 1,2,...,a2n the numbers in the set.
Input Format:
1<t< 100
1<s≤100
0<ai< 100
Output Format:
For each test case, print "Yes" if it can be split into exactly pairs so that the sum of the two elements in each pair Is
odd, and "No" otherwise. You can print each letter in any case.
Code:
#include <iostream>
int main()
int t;
cin>>t;
while(t--){
int n,odd=0;
cin>>n;
int z=power(n,odd);
power(n,z,1);
0 0
}
return 0;
int a[2*x];
for(int i=0;i<2*x;i++){
cin>>a[i];
0 0
if(a[i]%2==1)
p++;
}
return p;
if(x==y)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 1;
0 0
22.Problem Description:
Limka Book of Records has an online application facility for the public to register themselves and apply for the
specific achievement which will be taken into account for the entry in to the Limka Book of Records.
In their official website, once the user has registered themselves successfully it has to show the welcome message
"Hi" followed by his/her "First Name".
Similarly the when the user login into his account it has to show "Welcome" followed by "First name and last
name".
Function Description:
Input Format:
First and Second Line of Input has a single value of type string representing the First Name of the User.
Third line of input has a single value of type string representing the last name of the user.
Output Format:
Code:
#include <iostream>
class Welcomemsg{
public: 0 0
int main(){
Welcomemsgob;
string fname,lname;
cin>>fname;
ob.msg(fname);
cin>>fname>>lname;
ob.msg(fname,lname);
return 0; }
0 0
23.Problem Description:
Elavenil is the working in Survey of India, The National Survey and Mapping Organization of the country under the
Department of Science & Technology, which is the oldest Scientific Department of the Government of INDIA. It was
set up in 1767 and has evolved rich traditions over the years.
Now Elavenil has been assigned the task of Collecting the Area and Density Information of all the states of India
from the local authorities of the respective states and to consolidate in a common portal of Government of INDIA.
Since the task assigned to her is highly complicated in nature she is seeking your help.
Functional Description:
Constraints:
Input Format:
Only Line of input has three values of type string, Integer and integer separated by a space representing Slate
name, Area and Density of
State.
Output Format:
In four lines of output print the details of Country, State, Area and Density respectively in the expected format.
Code:
#include <iostream>
class Country{
public:
Country(){cout<<"Country:INDIA"<<endl;}
cout<<"State:"<<statename<<endl<<"Area:"<<area<<endl<<"Density:"<<density<<endl;
}; 0 0
int main()
{
Country country;
char statename[100];
0 0
int area,density;
cin>>statename>>area>>density;
Country statesofindia(statename,area,density);
return 0;
0 0
24.Problem Description:
Harsh the HR of a Google HQ in Bangalore is looking for the automated appraisal management system.
The current salary of the employee is fixed and based on the results of the performance monitoring software the
appraisal management system have to revise the salary of the employee.
Functional Description:
Use the Constructor Overloading Concept to develop automated appraisal management system.
Constraints:
30000<sal< 500000
Input Format:
Only line of input has a single value of type integer representing the New salary of the employee.
Output Format:
In the First Line of output print the Old salary of the employee.
0 0
In the Second Line of output print the New salary of the employee.
In the Third Line of output print the amount the employee got as hike.
Code:
#include <iostream>
class Appraisal {
int sal;
public:
Appraisal(){sal=30000;cout<<"Old Salary:"<<sal<<endl;}
Appraisal(int sal){cout<<"";}
};
int main() {
Appraisal oldsalary;
Appraisal newsalary(sal);
return 0; }
0 0
25.Question description
Saravanan wants to check his wrist watch time and clock in his car displayed a same time or not?
Constraints
0<hr<23
0<m<60
0<s<60
Input Format:
Output Format:
If time is same print, "Both clocks are showing the same time"
If the Invalid input, print "Invalid time format" and print the desired result in next line.
Code:
#include <iostream>
class Time
int h,m,s;
public:
Time(){cin>>h>>m>>s;}
void check()
if(h>23||m>59||s>59) 0 0
cout<<"Invalid time format\n";
}
};
0 0
if(h==t2.h&&m==t2.m&&s==t2.s)
return true;
else
return false;
int main()
Time t1,t2;
t1.check();
t2.check();
if(t1==t2)
else
return 0;
0 0
26.Question description:
Rahul and Ramesh are military officers. They are travelling to enjoy the vacation by train.
They are planned to play a game during their travel that they are interested in how many ways there are in
scrambling the letters.
One fellow should said the length of the word added by 1 and other fellow should give the number of ways the
letters to be scrambled.
For example, if suppose Rahul gave the length of the word is 6. Then Ramesh should be subtracted that 1 and
calculate for the word's length as 6-1. He have 5 choices for the first letter, once he have chosen the first letter
there are 4 choices for the second letter, and then three choices for the third letter, two for the fourth letter, and
only one choice for the last letter. Hence there are 5(4)(3)(2)[1] =
5=120 choices.
0 0
Can you help them to verify the answer?
Constraints:
1<n<10
Input Format:
Output Format:
Code:
#include <iostream>
class Scrum{
public:
int n;
Scrum(int h)
n=h;
--n;
0 0
return 1;
void display(){
int res=1;
for(int i=1;i<=n;i++){
res=res*i;
cout<<res;
};
int main()
int n;
cin>>n;
Scrum T(n);
T--;
T.display();
return 0;
0 0
0 0
27. Question description
The Wonderking in Wonderland had a great friend called Wondermath a professor in mathematics. The king and
the professor shared everything, they were same age, married same day, have same number of children etc.
To represent this friendship professor Wondermath introduced Amicable numbers, a pair who is friends like him
and king.
Amicable numbers are a pair of numbers with the following property: the sum of all of the proper divisors of the
first number (not including itself) exactly equals the second number while the sum of all of the proper divisors of
the second number (not including itself)
To satisfy his friend Wonderking, professor wants to find many Amicable numbers before the tea time tomorrow.
You must develop a program that declares a number is amicable or not in order to help professor WonderMath.
Constraints
1≤n1,n2<8000
Input Format
Output Format
If amicable numbers, print Friendly Pair. Otherwise print Not a Friendly Pair
Code:
#include <iostream>
class compare{
public:
int first,sum1=0;
compare(int x){
first=x;
void f(){
for(int i=1;i<=first/2;i++)
if(first%i==0)
sum1=sum1+i;
0 0
}
if(first==t2.sum1&&t2.first==sum1)
cout<<"Friendly Pair";
else 0 0
cout<<"Not a Friendly Pair";
}
};
int main()
int first,second;
cin>>first;
cin>>second;
compare t1(first),t2(second);
t1.f();
t2.f();
t1==t2;
return 0;
0 0
28. Question description
The task is to overload the /operator to divide the fraction with other fraction. You can take the numerator as num
and the denominator as deno.
Constraints
1<num, demo<10^7
Input Format
First line represents the value of numerator and the denominator of first fraction separated by a space
Second line represents the value of numerator and the denominator of second fraction separated by a space
Output Format
Otherwise
Note: If the denominator of any one of the input fractions is zero, then the error message "Error" will be displayed.
Explanation:
#include <iostream>
class Fraction{
public:
int num,den;
num=n;
den=d;
Fraction res;
0 0
res.num=num*obj.den;
res.den=den*obj.num;
return res;
void display1(){
cout<<num/den;
void display2(){
cout<<num<<"/"<<den;
void display3(){
cout<<"Error";
};
int main()
int a,b,c,d;
cin>>a>>b;
cin>>c>>d;
Fraction ob1(a,b),ob2(c,d);
Fraction ob3=ob1/ob2;
if(ob1.den==0||ob2.den==0)
cout<<"Error";
return 0;
if(ob3.den==1) 0 0
ob3.display1();
else
for(int i=2;i<50;i++)
{ 0 0
ob3.num=ob3.num/i;
ob3.den=ob3.den/i;
ob3.display2();
return 0;
0 0
29. Question description:
Vijay have taken charge as the Dean of the famous Medical college recently.
After taking over the high profile job he decided to fix all the obstacles faced by the patients visiting the medical
college in the past.
So he planned to create the automated Digital Display system which guides the incoming patients with the doctor
who will take care of them and the bed numbers which are allocated to them.
Input Format:
First line of input has a single value of type string representing the name of the Doctor.
Second line of input has a single value of type string representing the Degree of the Doctor.
Third line of input has a single value of type string representing the name of the patient.
Third line of input has a single value of type integer representing the bed number of the patient.
0 0
Constraints:
100<bedno<500
Output Format:
Code:
#include <iostream>
class doctor
public:
string name,degree,pname;
int no;
void getedu()
cin>>name>>degree>>pname;
void getdata()
0 0
cin>>no;
void dispedu()
void dispdata()
cout<<"Bed Number:"<<no<<endl;
};
};
int main()
patient p;
p.getedu();
p.getdata();
p.dispedu();
p.dispdata();
return 0;
} 0 0
0 0
30. Question description:
During her designing process she used to calculate the perimeter of different part of equipment she needs to
design in a 3D environment and update in her design book.
So to avoid confusion she is looking for the automated perimeter measurement tool.
So she will be happy if you can help her with such as tool.
Constraints:
100<length<5000
100<breadth≤5000
Input Format:
Only line of input has a two value of type integer representing length and breadth measurements respectively.
Output format:
Code:
#include <iostream>
class ReceiveMesurement {
public:
int l,b,r;
void perimeter()
cin>>l>>b;
r=l+b+l+b;
cout<<r<<endl; } };
int main()
CalculatePerimeter mt;
mt.perimeter(); return 0; }
0 0
55. Question description:
The document processor Dino uses accepts only characters which are alphabetic in nature.
Can you help Dino in finding the nature of the characters in the document Dino is working with?
Input Format:
First line of input has a single value of type integer representing the number of testcases.
Output Format:
Code:
#include<bits/stdc++.h>
int main() {
int t,i,j;
cin>>t;
string str;
f(j,0,t)
f(i,0,2){
try{
cin>>str[i];
if(isalpha(str[i]))
cout<<str[i]<<" is alphabetic"<<endl;
else
throw str[i];
0 0
56. Problem Description:
Binita is playing a chess. The game will be played on a rectangular grid consisting of N rows and M columns. Initially
all the cells of the grid are uncolored.
Binita's initial score is zero. At each turn, he chooses some cell that is yet not colored, and colors that cell. The
score obtained in this step will be number of neighboring colored cells of the cell that Binita colored in this step.
Two cells are neighbors of each other if they share a side between them. The game will end when all the cells are
colored. Finally, total score obtained at the end of the game will sum of score obtained in each turn.
Binita wants to know what maximum score he can get? Can you please help him in finding this out?
Constraints:
1 ≤N, M≤ 50
Input Format:
The Only line of input contains two space-separated integers N, M denoting the dimensions of the grid.
Output Format:
Print the output a single line containing an integer corresponding to the maximal possible score Binita can obtain.
Code:
#include <iostream>
int main() {
int n,m;
try{
cin>>n;
cin>>m;
if(cin){
cout<<n-1+(1+2*(n-1))*(m-1);
else
throw 0;
catch(int griddimensions)
return 0; }
0 0
57. Problem Description:
During the discussion Jannu asked Preethi, what will be the area of this Pyramid.
Functional Description:
Constraints:
Input Format:
The only line of input has two floating point values representing height and base respectively separated by a space.
Output Format:
In the only line of output print the area of the pyramid with only three values after decimal point.
Code:
#include <bits/stdc++.h>
int main() {
float height,base;
try{
cin>>height;
cin>>base;
if(cin){
cout<<fixed<<setprecision(3)<<base*height/2;
else
throw 0;
catch(int cal) {
0 0
58. Question description
Vijayan the Mathematics Professor has his own belief that only +,-./ and * are valid operators.
Now he given the students the set of numbers and operators his students to check whether the given operator is
valid or not.
Function Description
Based on the result of the operation print the result or exception based on the condition.
Constraints
1<op1≤1000
1<op2≤1000
Input Format:
Only line of input has Operand1 Operator and Operand 2 separated by as space.
Output Format:
Print 5 values after decimal point if the result of the operation have a decimal point.
Code:
#include <iostream>
int main()
char opr;
float op1,op2;
try{
cin>>op1>>opr>>op2;
if(cin){
if(opr=='+')
{ cout<<op1<<"+"<<op2<<"="<<op1+op2;}
else if(opr=='-')
{ cout<<op1<<"-"<<op2<<"="<<op1-op2;}
else if(opr=='/')
{ cout<<op1<<"/"<<op2<<"="<<op1/op2;}
else if(opr=='*')
0 0
{ cout<<op1<<"*"<<op2<<"="<<op1*op2;}
else
}else
}catch(int op)
0 0
59. Problem Description:
Phoenix mall in the capital city of Washington and it is rectangular in shape when it is seen on the map with the
size n x m meters.
On the occasion of the jubilee anniversary, a decision was taken to pave the Square with square marbles stones.
Each stone is of the size axa.
Can you find what is the least number of stones needed to pave the Square?
It's allowed to cover the surface larger than the Mall Square, but the Square has to be covered.
The sides of stones should be side by side(parallel) to the sides of the Square.
Constraints:
1 ≤n ≤ 10^9
1 ≤m≤ 10^9
1 ≤a≤ 10^9
Input Format:
The only line of input contains three positive integer numbers n, m and a separated by a space.
Output Format:
If any of the input values n or m or a is missing in the input then raise the exception message as "Invalid
Dimension".
Code:
#include <iostream>
int main() {
int n,m,a;
try{
cin>>n>>m>>a;
if(cin){
cout<<((n+a-1)/a)*((m+a-1)/a);
else
throw 0; }
0 0
60. Problem Description:
Tina's trainer have given her two positive integers U and V. Now her task is ti find the number of pairs of positive
integers (X,Y) such that 1<x<U, 1sY<V and X+Y is even.
Constraints
1<U,V<75
Input Format:
The only line of each test case contains two space-separated integers U and V.
Output Format:
In the only line of output print a single line containing one integer that represents the the number of valid pairs.
Code:
#include <iostream>
int main()
int U,V;
try{
cin>>U>>V;
if(cin){
cout<<U*V/2+((U%2)*(V%2));
else
throw 0;
catch(int Number)
return 0;
0 0
61. Question description:
Virat in his recent examination got very bad marks in algebra again. To avoid such unpleasant events in future he
decided to train his arithmetic skills. He wrote four integer numbers a, b, c, d on the blackboard.
During each of the next three minutes he took two numbers from the blackboard (not necessarily adjacent) and
replaced them with their sum or their product. In the end he got one number.
Unfortunately, due to the awful memory he forgot that number, but he remembers four original numbers,
sequence of the operations and his surprise because of the very small result.
Help Virat remember the forgotten number to find the smallest number that can be obtained from the original
numbers by the given sequence of operations.
Constraints:
0≤ a, b, c, d≤ 1000
Input Format:
First line contains four integers separated by space representing the the original numbers.
Second line contains three signs ('+' or '*' each) separated by space representing the sequence of the operations in
the order of performing. ("+' stands for addition, *** - multiplication)
Output Format:
Output one integer number representing the minimal result which can be obtained.
Code:
#include <bits/stdc++.h>
long longans=1e15;
deque<char>Operations(20);
if((int)a.size()==1){
ans=min(ans,a[0]);
return; }
for(int i=0;i<(int)a.size();i++){
for(int j=0;j<i;j++){
vector<long long> b;
if(Operations[id]=='+') b.push_back(a[i]+a[j]);
else b.push_back(a[i]*a[j]);
for(int k=0;k<(int)a.size();k++){
0 0
if(k!=i&& k!=j) b.push_back(a[k]);
solve(b,id+1);
int main() {
vector<long long>numbers(4);
solve(numbers,0); cout<<ans;
return 0;
0 0
62. Question description:
Tina is walking in the forest and picking a bouquet from fallen leaves. Tina is very choosy, she doesn't take a leaf if
it matches the color and the species of the tree of one of the leaves she already has.
Constraints:
1≤n≤100
Input Format:
The first line contains an integer n representing the number of leaves Tina has found.
Each leaf is characterized by the species of the tree it has fallen from and by the color.
The species of the trees and colors are given in names, consisting of no more than 10 lowercase Latin letters.
The species of a tree and the color are given in each line separated by a space.
Output Format:
Code:
#include <bits/stdc++.h>
int main()
int n;
cin>>n;
set<pair<string,string>>Descriptionofleaves;
string species,color;
while(n--){
cin>>species>>color;
Descriptionofleaves.insert(make_pair(species,color));
cout<<Descriptionofleaves.size();
return 0; }
0 0
63. Question description:
The teacher, on the other hand, is required to make the shapes according to the measurements.
Input Format:
Only line of input has a 4 value of type integer representing width of rectangle, height of rectangle, width of
triangle and height of triangle respectively.
Output Format:
Code:
#include <iostream>
class polygon{
public:
};
public:
int e,f;
e=a;
f=b;
};
public:
int g,h;
g=c;
0 0
h=d;
};
int main()
int a,b,c,d;
cin>>a>>b;
cin>>c>>d;
rectangle rect;
rect.input(a,b);
triangle tri;
tri.input(c,d);
return 0;
0 0
64. Question description:
Ragu requires basic staff information in order to properly maintain the files.
The sequence of the Google sheet is as follows: first name, last name, gender, college name, and category.
Input Format:
Output Format:
Code:
#include <iostream>
#include <bits/stdc++.h>
class person
private:
char fname[100],lname[100],gender[10];
protected:
int age;
public:
void input_person();
void display_person();
};
0 0
private:
char college_name[100];
char level[20];
public:
void input_student();
void display_student();
};
void person::input_person(){
cin>>fname>>lname>>gender>>age;
void person::display_person()
cout<<"First Name:"<<fname<<endl;
cout<<"Last Name:"<<lname<<endl;
cout<<"Gender:"<<gender<<endl;
cout<<"Age:"<<age<<endl;
void student::input_student()
person::input_person();
cin>>college_name>>level;
void student::display_student()
{ person::display_person();
cout<<"College:"<<college_name<<endl;
cout<<"Level:"<<level<<endl; }
int main() {
student s;
s.input_student();
s.display_student();
return 0; }
0 0
65. Question description:
Some customers may have taken a loan from the bank. So bank always maintains information about bank
depositors and borrow owers.
Write necessary member functions to read and display the details of 'n'
Input Format:
Output Format:
Code:
#include <iostream>
class customer{
public:
int no;
string name;
void acceptc(){
cin>>name>>moblie>>no;
} };
0 0
public:
int bal;
void acceptd(){
cin>>bal;
void dispd(){
cout<<"Customer Name:"<<name<<endl;
cout<<"Balance:"<<bal<<endl;
} };
public:
void acceptb(){
cin>>loan_no>>amt;
void dispb(){
cout<<"Loan No:"<<loan_no<<endl;
cout<<"Loan Amount:"<<amt<<endl;
} };
int main(){
int n;
cin>>n;
borrow b1[n];
for(int i=0;i<n;i++){
b1[i].acceptc();
b1[i].acceptd();
b1[i].acceptb();
b1[i].dispd();
b1[i].dispb(); } return 0; }
0 0
66. Question description:
Roahn and Lokesh are very close friends, they cannot go and play games during this lockdown.
Roahn gives a number to Lokesh and he has to find the answer for the number he is getting from Roahn.
Constraints:
1<number<1000
Input Format:
Only line of input has a single value of type integer representing the number provided by Rohan.
Output format:
Code:
#include <iostream>
#include <cmath>
class top{
};
};
public:
int a;
void getdata(){
cin>>a;
void square(){
int b=2;
0 0
int s=pow(a,b);
cout<<s<<endl;
void cube(){
int d=3;
int c=pow(a,d);
cout<<c;
};
int main()
bottom calc;
calc.getdata();
calc.square();
calc.cube();
return 0;
0 0
67. Question description:
The programme unexpectedly crashed, so Ravindran is having an issue with completing the salary slip on time.
Please assist him in preparing the salary slip so that he may submit it on time.
Input Format:
Output Format:
Code:
#include <bits/stdc++.h>
#include <strings.h>
class Employee
public:
};
public:
int netpay,bs,hra,da,pf,empcode;
string empname,emprole;
void getEmpDetails()
0 0
{
cin>>empcode>>empname>>emprole;
void getPayDetails()
cin>>bs>>hra>>da>>pf;
void calculate()
netpay=bs+hra+da-pf;
void display()
cout<<"Employee Number:"<<empcode<<endl;
cout<<"Employee Name:"<<empname<<endl;
cout<<"Employee Role:"<<emprole<<endl;
};
int main()
Salary s;
s.getEmpDetails();
s.getPayDetails();
s.calculate();
s.display();
return 0;
0 0
0 0
38. Question Description:
Purushothaman trying a non-empty string is called palindrome if it reads the same from the left to the right and
from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "XY" are not.
A string is called a substring of another string if it can be obtained from that string by dropping some (possibly
zero) number of characters from the beginning and from the end of it. For example, "ABC", "ab", and "c" are
substrings of the string "ABC", while "ac" and "d" are not.
Let's define a palindromic count of the string as the number of its substrings that are palindromes. For example,
the palindromic count of the string "aaa" is 6 because all its substrings are palindromes, and the palindromic count
of the string "ABC" is 3 because only its substrings of length 1 are palindromes.
You are given a strings. You can arbitrarily rearrange its characters. Your goal is to obtain a string with the
maximum possible value of palindromic count.
Constraints:
1<n<100000
Input Format:
The second line contains strings that consists of exactly n lowercase characters of the Latin alphabet.
Output Format:
Print string t, which consists of the same set of characters (and each character appears exactly the same number of
times) as string s. Moreover, t should have the maximum possible value of palindromic count among all such
strings.
Code:
#include <bits/stdc++.h>
class passPal
public:
int n;
void count()
0 0
{
cin>>n;
}
};
class arbitrary:publicpassPal
0 0
{
public:
void goal()
char c[100000];
cin>>c;
sort(c,c+n);
cout<<c;
};
int main(){
arbitrary a;
a.count();
a.goal();
0 0
39. Question description:
Young Varun has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a
number ai, which is written on it.
Varun put all the cubes in a row and went to unpack other presents.
In this time, Varun's elder brother, Saran reordered the cubes using the following rule. Suppose the cubes are
numbered from 1 to n in
their order.
Saran performs several steps, on step i he reverses the segment of cubes from ith to (n-i+ 1)-th. He does this while
i≤ n-i+ 1.
After performing the operations Saran went away, being very proud of himself.
When Varun returned to his cubes, he understood that their order was changed.
Help Varun as fast as you can and save the holiday - restore the initial order of the cubes using information of their
0 0
current location.
Constraints:
1 ≤n≤2.10
Input Format:
The first line contains single integer n representing the number of cubes.
The second line contains n integers ₁, 2, an where a; is the number written on the ith cube after Saran has changed
their order.
Output Format:
Print n integers, separated by spaces - the numbers written on the cubes in their initial order.
Code:
#include <iostream>
class Gift {
};
public:
int a[10],n;
void Cubes(){
0 0
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n/2;i+=2)
/*int temp=a[i];
a[i]=a[n-i-1;
a[n-i-1]=temp;*/
swap(a[i],a[n-i-1]);
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
};
int main()
Birthday obj;
obj.Cubes();
return 0;
0 0
0 0
40. Question description
Balaji's n friends are planning to spend the night at his house. Balaji has n beds standing in a row and m pillows
(n≤m).
Each friend needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible.
Of course, it's not always possible to share pillows equally, but any friend gets hurt if he has at least two pillows
less than some of his neighbors have.
What is the maximum number of pillows he can have so that every friend has at least one pillow, every pillow is
given to some friend and no one is hurt?
Constraints:
1≤n≤m≤10⁹
1≤ksn
Input Format:
The only line contain three integers n, m and k representing the number of hobbits, the number of pillows and the
number of Balaji's bed.
Output Format:
Print single integer representing the maximum number of pillows Balaji can have so that no one is hurt.
Code:
#include <iostream>
class StayatHome {
};
class Friends:publicStayatHome{
public:
int n,m,k,a=1,c=1;
void Beds() {
cin>>n>>m>>k;
m-=n;
while(m>0){
if(k+a<=n) c++;
if(k-a>=1) c++;
0 0
m-=c;
a++;
cout<<a;
};
0 0
int main()
{
Friends obj;
obj.Beds();
return 0;
0 0
41. Question description:
Idumban Karri's friend Soman Santhavan given him two integers n and k.
Soman asked Idumban to find k-th smallest divisor of n, or report that it doesn't exist.
Divisor of n is any such natural number, that n can be divided by it without remainder.
Constraints:
1≤n≤ 1015
1≤ks 10⁹
Input Format:
Code:
#include <iostream>
class Problem {
};
int n,k,i;
void Divisor(){
cin>>n>>k;
int Display()
int count;
for(i=1;i<=n;++i)
if(n%i==0)
count++;
if(count==k){
0 0
cout<<i;
return 1;
cout<<-1;
return 1;
};
int main()
Calculation obj;
obj.Divisor();
obj.Display();
return 0;
0 0
42. Question description:
The final statistics needs to be submitted to the CEO of the company today.
Since the number of people working in the firm is huge Ravindran is finding it difficult to format the data.
Constraints:
1000 ≤salary≤150000
Input Format:
First line of input has a single value of type integer representing the salary of Developer.
Second line of input has a single value of type integer representing the salary of Driver.
Output Format:
Code:
#include <iostream>
class Employee{
public:
int s1,s2;
};
public:
void getSalary(){
cin>>s1;
cout<<"Salary of Developer:"<<s1<<endl;
};
public:
0 0
void getSalary(){
cin>>s2;
cout<<"Salary of Driver:"<<s2<<endl;
};
int main()
Developer d1;
Driver d2;
d1.getSalary();
d2.getSalary();
return 0;
} 0 0
0 0
43. Question description:
Fazil owns a Super Market in the location which is the heart of the city.
So people who visits his Super market are always in a hurry and dosen't have patience to wait in the Bill counter.
So to avoid loosing customers Fazil is looking for the automated programming logic which can get the details of the
purchase and estimate the total price of the purchase.
Constraints:
1≤code≤500
1≤qty≤1000
1<price<10000
Input Format:
First line of input has a single value of type string representing the Name of the Customer.
Second line of input has a single value of type Integer representing the Item code.
Third line of input has a single value of type Integer representing the Telephone number of the Customer.
Fourth line of input has a single value of type Integer representing the quantity of the item purchased by the
Customer.
Fifth line of input has a single value of type Integer representing the price of the item purchased by the Customer.
Output Format:
Code:
#include <iostream>
class consumer{
public: 0 0
string name;
virtual void getdata()=0;
};
public:
0 0
0 0
78. Question Description:
Gabbi has given a grid, consisting of 2 rows and n columns. Each cell of this grid should be colored either black or
white.
Two cells are considered neighbors if they have a common border and share the same color. Two cells A and B
belong to the samame component if they are neighbors, or if there is a neighbor of A that belongs to the same
component with B.
Count the number of beautiful colorings. The number can be big enough, so print the answer modulo 998244353.
Constraints:
1≤n≤1000
1<k<2n
Input Format:
The only line contains two integers n and k the number of columns in a grid and the number of components
required.
Output Format:
Code:
#include <bits/stdc++.h>
#define M 998244353
class coloring
public:
void black(){
int n,k;
cin>>n>>k;
A[1][1] = 2;
B[1][2] = 2;
for(int i=2;i<=n;i++)
for(int j=1;j<=2*i;j++)
0 0
{
cout<<(A[n][k]+B[n][k])%M;
};
public:
void white(){
};
int main()
border bd;
bd.black();
bd.white();
0 0
79. Question description:
Fazil is an athlete from his school time. Now he joined his under graduation in a famous institution which
motivates students who are in sports. The Institution even provides scholarships for the sports quota.
So Fazil planned to apply for the scholarship for which he needs to calculate the percentage which considers the
marks of CT1,CT2 and
Constraints:
1<m1≤100
1<m2≤100
1<sm≤100
Input Format:
Output format:
Code:
#include <iostream>
class student {
public:
int reg,ct1,ct2,sm;
float tot,per;
void get() {
cin>>reg>>ct1>>ct2>>sm;
void getsm() {
0 0
tot=ct1+ct2+sm;
per=tot/3;
void display() {
cout<<reg<<endl<<tot<<endl<<per<<endl;
};
class sports {
public:
};
};
int main()
statement obj;
obj.get();
obj.getsm();
obj.display();
return 0;
0 0
80. Question Description:
Sandi has come to the exhibition and one exhibit has drawn your attention. It consists of n stacks of blocks, where
the i-th stack consists of at blocks resting on the surface.
The height of the exhibit is equal to m. Consequently, the number of blocks in each stack is less than or equal to m.
There is a camera on the ceiling that sees the top view of the blocks and a camera on the right wall that sees the
side view of the blocks.
Find the maximum number of blocks you can remove such that the views for both the cameras would not change.
Note, that while originally all blocks are stacked on the floor, it is not required for them to stay connected to the
floor after some blocks are removed. There is no gravity in the whole exhibition, so no block would fall down, even
if the block underneath is removed. It is not allowed to move blocks by hand either.
Constraints:
1≤n≤100000,
1<m≤10^9
1<a,i<m
Input Format:
The first line contains two integers n and m the number of stacks and the height of the exhibit.
The second line contains n integers al,a2,...,an the number of blocks in each stack from left to right.
Output Format:
Print exactly one integer the maximum number of blocks that can be removed.
Code:
#include <bits/stdc++.h>
int64_t n,c,s,i,a[179000];
class exhibition
public:
void blocks()
for(cin>>n>>a[0];i<n;i++)cin>>a[i],s+=a[i];
sort(a,a+n);
for(i=0;i<n;i++)c+=a[i]>c;
cout<<s-n-a[n-1]+c;
0 0
}
};
public:
void surface(){
};
int main(){
attention atn;
atn.blocks();
atn.surface();
0 0
81. Question Description:
VSR and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an
array al, a2, ..., an of integers, such that 1<al<a2<...<an<103, and then went to the bathroom.
VSR decided to prank his friend by erasing some consecutive elements in the array. Since he doesn't want for the
prank to go too far, he will only erase it in a way, such that Giraffe can still restore the array using the information
from the remaining elements.
Because Giraffe has created the array, he's also aware that it's an increasing array and all the elements are integers
in the range [1,10^3].
Constraints:
1≤n≤100
1<al<a2<...<an<10^3
Input Format:
The first line of the input contains a single integer n the number of elements in the array.
The second line of the input contains n integers at the array is written by Giraffe
Output Format:
Print a single integer the maximum number of consecutive elements in the array that VSR can erase.
Code:
#include<bits/stdc++.h>
int n, a[MAXN];
class friends
public:
void Giraffe()
scanf("%d", &n);
n++;
a[n] = 1001;
0 0
int ans = 0;
printf("%d\n", ans);
};
};
int main()
prank p;
p.Giraffe();
return 0;
cout<<"p.far();";
0 0
82. Question Description:
There are n benches in Anna Central park. It is known that at people are currently sitting on the i-th bench. Other
m people are coming to the park and each of them is going to have a seat on some bench out of n available.
Let k be the maximum number of people sitting on one bench after additional m people came to the park.
Calculate the minimum possible k and the maximum possible k.
Constraints:
1≤n≤100
1≤m≤10000
1 ≤ai≤ 100
Input Format:
The first line contains a single integer n the number of benches in the park.
The second line contains a single integer m the number of people additionally coming to the park.
Each of the next n lines contains a single integer at the initial number of people on the i-th bench.
Output Format:
Print the minimum possible k and the maximum possible k, where k is the maximum number of people sitting on
one bench after additional m people came to the park.
Code:
#include <bits/stdc++.h>
class centralPark
public:
void possible()
int n, m;
int x = 0, s = 0, t;
cin >> t;
x += t;
0 0
s = max(s, t);
};
class Bench:publiccentralPark
public:
void available()
};
int main(){
Bench bh;
bh.possible();
bh.available();
0 0
83. Question Description:
Two players A and B have a list of n integers each. They both want to maximize the subtraction between their
score and their opponent's score.
In one turn, a player can either add to his score any element from his list (assuming his list is not empty), the
element is removed from the list afterward. Or remove an element from his opponent's list (assuming his
opponent's list is not empty).
Note, that in case there are equal elements in the list only one of them will be affected in the operations above.
For example, if there are elements {1,2,2,3} in a list and you decided to choose 2 for the next turn, only a single
instance of 2 will be deleted (and added to the
score, if necessary).
Player A starts the game and the game stops when both lists are empty. Find the difference between A's score and
B's score at the end of the game, if both of the players are playing optimally.
Optimal play between two players means that both players choose the best possible strategy to achieve the best
possible outcome for themselves. In this problem, it means that each player, each time makes a move, which
maximizes the final difference between his score and his opponent's score, knowing that the opponent is doing the
same.
Constraints:
1≤n≤100000
1≤ai≤ 10^6
1≤bi≤ 10^6
Input Format:
The first line of input contains an integer nthe sizes of the list.
The second line contains n integers at, describing the list of player A, who starts the game.
The third line contains n integers bi, describing the list of player B.
Output Format:
Output the difference between A's score and B's score (A-B) if both of them are playing optimally.
Code:
#include<bits/stdc++.h>
class players
public:
void elements()
0 0
int x,i;
cin>>x;
int n[x+x];
for(i=0;i<x;i++)
cin>>n[i]; s+=n[i];
for(i=x;i<2*x;i++)
cin>>n[i];
sort(n,n+(2*x));
for(i=0;i<2*x;i+=2)
s-=n[i];
cout<<s<<endl;
};
public:
void instance()
};
int main()
score s;
s.elements();
s.instance();
0 0
84. Question Description:
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced
by a digit.
For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000"
are not.
You have n cards with digits, and you want to use them to make as many phone numbers as possible.
Each card must be used in at most one phone number, and you don't have to use all cards. The phone numbers do
not necessarily have to be distinct.
Constraints:
1≤n≤100
Input Format:
The first line contains an integer n the number of cards with digits that you have.
The second line contains a string of n digits (characters "0", "1", ..., "9") s1,s2,...,sn. The string will not contain any
such as leading or trailing spaces. other characters,
Output Format:
If at least one phone number can be made from these cards, output the maximum number of phone numbers that
can be made.
Otherwise, output 0.
Code
#include<bits/stdc++.h>
class pattern
public:
void digit()
string s;
int n,c=0;
cin>>n>>s;
for(auto i:s){
c+=i=='8';
0 0
cout<<min(c,n/11);
};
public:
void cards()
};
int main(){
number num;
num.digit();
num.cards();
0 0
85. Question description:
Let's define a split of nn as a nonincreasing sequence of positive integers, the sum of which is nn.
For example, the following sequences are splits of 8: [4,4], [3,3,2], [2,2,1,1,1,1], [5,2,1].
The weight of a split is the number of elements in the split that are equal to the first element. For example, the
weight of the split [1,1,1,1,1] is 5, the weight of the split [5,5,3,3,3] is 2 and the weight of the split [9] equals 1.
For a given n, find out the number of different weights of its splits.
Constraints:
1≤n≤10^9
Input Format:
Output Format:
Code:
#include <iostream>
int n;
class Sequence
std::cin>>n;
std::cout<<n/2+1;
};
int main()
Sequence obj;
obj.Split();
0 0
86. Question description:
The people are numbered from 1 to k, and Firaz is the first of them.
To split the candies, Firaz will choose an integer x and then give the first x candies to himself, the next x candies to
the second person, the next x candies to the third person and so on in a cycle.
The leftover (the remainder that is not divisible by x) will be thrown away.
Also, he can't choose such a small x that some person will receive candies more than D times, as it is considered a
slow splitting.
Please find what is the maximum number of candies Firaz can receive by choosing some valid x.
Constraints:
2≤n≤10^18
2<ksn
1<D<min(n,1000)
Input Format:
The only line contains four integers n, k, M and D -- the number of candies, the number of people, the maximum
number of candies given to a person at once, the maximum number of times a person can receive
Output Format:
Print a single integer - the maximum possible number of candies Firaz can give to himself.
Code:
#include <bits/stdc++.h>
class Candies
long longn,k,m,d,ans=0;
cin>>n>>k>>m>>d;
for(int i=1;i<=d&&k*(i-1)+1<=n;i++)
ans=max(ans,i*min(m,n/(k*(i-1)+1)));
0 0
cout<<ans;
};
int main(){
Candies obj;
obj.Split();
0 0
87. Question Description:
James has n different boxes. The first of them contains some balls of n different colors.
James wants to play a strange game. He wants to distribute the balls into boxes in such a way that every i (1 ≤i≤n)
ith box will contain all balls with color i.
In order to do this, James will make some turns. Each turn he does the following:
1. James chooses any non-empty box and takes all balls from this box;
2. Then James chooses any k empty boxes (the box from the first step becomes empty, and James is allowed to
choose it), separates the balls he took on the previous step into k non-empty groups, and puts each group into one
of the boxes. He should put each group into a separate box. He can choose either k = 2 or k= 3.
The penalty of the turn is the number of balls James takes from the box during the first step of the turn. And the
penalty of the game is the total penalty of turns made by James until he distributes all balls to corresponding
boxes.
Constraints:
1 ≤n≤200000
1 ≤ a,≤ 10⁹
Input Format:
The first line contains one integer number n the number of boxes and colors.
The second line contains n integer numbers ₁, 2, ..., an, where a, is the number of balls with color i.
Output Format:
Code:
#include <bits/stdc++.h>
class boxes
public:voidcolorBalls()
lln,a,ans=0;
priority_queue<ll,vector<ll>,greater<ll>>pq;
cin>>n;
0 0
if(!(n&1)) pq.push(0);
while(pq.size()!=1){
a=pq.top();pq.pop();
a+=pq.top();pq.pop();
a+=pq.top();pq.pop();
ans+=a;
pq.push(a);
cout<<ans;
};
int main(){
boxes b;
b.colorBalls();
0 0
51. Question description:
Rome the capital city of Lazio Region is rectangular in shape with the size nxm meters.
On the occasion of the POPE's Birthday Celebration, a decision was taken to pave the Square with square granite
flagstones. Each
Now Rommi who lives in Rome would like to know the least number of flagstones needed to pave the Square?
It's allowed to cover the surface larger than Rome, but the Square has to be covered.
Constraints:
0≤n, m≤ 105
Input Format:
The input contains three positive integer numbers in the first line: n, m and aThe numbers a, b and c can coincide.
Output Format:
Code:
#include <iostream>
0 0
using namespace std;
cout<<((b+c-1)/c)*((a+c-1)/c);
return 1;
int main()
int a,b,c;
cin>>a>>b>>c;
Rome(a,b,c);
return 0;
0 0
52. Question description:
As a result of the recent Taliban Attack on Afgan Magical Clock the Central attraction of the city Kabul is damaged.
The bullets of the gun made several holes in the clock, that's why the residents are concerned about the repair.
The Magical clock can be represented as an infinite Cartesian plane, where the origin corresponds to the clock
center. The clock was
Your task is to find the color of the area, damaged by the given ball.
All the points located on the border of one of the areas have to be considered painted black.
Constraints:
Each of the numbers x and y has an absolute value that does not exceed 1000.
Input Format:
The first and single line contains two integers x and y representing the coordinates of the hole made in the clock by
the ball.
Output Format:
All the points between which and the origin of coordinates the distance is integral-value are painted black.
Code:
#include <iostream>
#include <cmath>
int c;
c=sqrt(x*x+y*y);
if(c*c==x*x+y*y){
cout<<"black\n";
return 0; 0 0
}
if(x*y<0)
c++;
if(c%2==0) 0 0
cout<<"black";
else cout<<"white";
return 1;
int main()
int x,y;
cin>>x>>y;
MagicClocl(x,y);
return 0;
0 0
53. Question description:
In his last class he he thought his students the factorial and the way to calculate the same.
So in todays class he assigned his student the task of writing a programming logic for implementing the factorial
calculation.
Input Format:
Output Format:
Print either the result of the factorial calculation and throw the error message if anything other than the integer is
provided as input.
Code:
#include <bits/stdc++.h> 0 0
#include <string.h>
using namespace std;
int main()
int k;
try
cin>>k;
if(cin)
cout<<fixed<<setprecision(0)<<tgamma(k+1);
else
throw "e";
return 0;
0 0
54. Question description:
Bharat loves to experiment with strings and one fine day he decided to check if two names matches with each
other.
So he now tried to create a programming logic for the same but finding it difficult.
Input Format:
Output Format:
And throw the error message "Inappropriate Input" if anything other than the string is provided as input.
Code:
#include <iostream>
int main()
string str1,str2;
try
cin>>str1>>str2;
if(cin) 0 0
{
for(int i=0;i<n;i++)
throw 0;
if(str1[i]==str2[i])
count++;
0 0
}
if(count!=n)
else
cout<<str1<<" is "<<str2;
catch (int i)
cout<<"Inappropriate Input";
return 0;
0 0
55. Question description:
The document processor Dino uses accepts only characters which are alphabetic in nature.
Can you help Dino in finding the nature of the characters in the document Dino is working with?
Input Format:
First line of input has a single value of type integer representing the number of testcases.
Code:
#include<bits/stdc++.h>
int main() {
int t,i,j;
cin>>t;
string str;
f(j,0,t)
f(i,0,2){
try{
cin>>str[i];
if(isalpha(str[i]))
cout<<str[i]<<" is alphabetic"<<endl;
else
throw str[i];
0 0
56. Problem Description:
Binita is playing a chess. The game will be played on a rectangular grid consisting of N rows and M columns. Initially
all the cells of the grid are uncolored.
Binita's initial score is zero. At each turn, he chooses some cell that is yet not colored, and colors that cell. The
score obtained in this step will be number of neighboring colored cells of the cell that Binita colored in this step.
Two cells are neighbors of each other if they share a side between them. The game will end when all the cells are
colored. Finally, total score obtained at the end of the game will sum of score obtained in each turn.
Binita wants to know what maximum score he can get? Can you please help him in finding this out?
Constraints:
1 ≤N, M≤ 50
Input Format:
The Only line of input contains two space-separated integers N, M denoting the dimensions of the grid.
Output Format:
Print the output a single line containing an integer corresponding to the maximal possible score Binita can obtain.
Code:
#include <iostream>
int main() {
int n,m;
try{
0 0
cin>>n;
cin>>m;
if(cin){
cout<<n-1+(1+2*(n-1))*(m-1);
else
throw 0;
catch(int griddimensions)
return 0; }
0 0
57. Problem Description:
During the discussion Jannu asked Preethi, what will be the area of this Pyramid.
Functional Description:
Constraints:
Input Format:
The only line of input has two floating point values representing height and base respectively separated by a space.
Output Format:
In the only line of output print the area of the pyramid with only three values after decimal point.
Code:
#include <bits/stdc++.h>
int main() {
float height,base;
try{
cin>>height;
cin>>base;
if(cin){
cout<<fixed<<setprecision(3)<<base*height/2;
else
throw 0;
catch(int cal) {
0 0
cout<<"Incomplete Information"; } return 0; }
58. Question description
Vijayan the Mathematics Professor has his own belief that only +,-./ and * are valid operators.
Now he given the students the set of numbers and operators his students to check whether the given operator is
valid or not. 0 0
Function Description
Based on the result of the operation print the result or exception based on the condition.
Constraints
1<op1≤1000
1<op2≤1000
Input Format:
Only line of input has Operand1 Operator and Operand 2 separated by as space.
Output Format:
Print 5 values after decimal point if the result of the operation have a decimal point.
Code:
#include <iostream>
int main()
char opr;
float op1,op2;
try{
cin>>op1>>opr>>op2;
if(cin){
if(opr=='+')
{ cout<<op1<<"+"<<op2<<"="<<op1+op2;}
else if(opr=='-')
{ cout<<op1<<"-"<<op2<<"="<<op1-op2;}
else if(opr=='/')
{ cout<<op1<<"/"<<op2<<"="<<op1/op2;}
else if(opr=='*')
0 0
{ cout<<op1<<"*"<<op2<<"="<<op1*op2;}
else
}else
}catch(int op)
0 0
0 0
59. Problem Description:
Phoenix mall in the capital city of Washington and it is rectangular in shape when it is seen on the map with the
size n x m meters.
On the occasion of the jubilee anniversary, a decision was taken to pave the Square with square marbles stones.
Each stone is of the size axa.
Can you find what is the least number of stones needed to pave the Square?
It's allowed to cover the surface larger than the Mall Square, but the Square has to be covered.
The sides of stones should be side by side(parallel) to the sides of the Square.
Constraints:
1 ≤n ≤ 10^9
1 ≤m≤ 10^9
1 ≤a≤ 10^9
Input Format:
The only line of input contains three positive integer numbers n, m and a separated by a space.
Output Format:
If any of the input values n or m or a is missing in the input then raise the exception message as "Invalid
Dimension".
Code:
#include <iostream>
int main() {
int n,m,a;
try{
cin>>n>>m>>a;
0 0
if(cin){
cout<<((n+a-1)/a)*((m+a-1)/a);
}
else
throw 0; }
0 0
60. Problem Description:
Tina's trainer have given her two positive integers U and V. Now her task is ti find the number of pairs of positive
integers (X,Y) such that 1<x<U, 1sY<V and X+Y is even.
Constraints
1<U,V<75
Input Format:
The only line of each test case contains two space-separated integers U and V.
Output Format:
In the only line of output print a single line containing one integer that represents the the number of valid pairs.
Code:
#include <iostream>
int main()
int U,V;
try{
cin>>U>>V;
if(cin){
cout<<U*V/2+((U%2)*(V%2));
else
throw 0;
catch(int Number)
return 0;
0 0
61. Question description:
Virat in his recent examination got very bad marks in algebra again. To avoid such unpleasant events in future he
decided to train his arithmetic skills. He wrote four integer numbers a, b, c, d on the blackboard.
During each of the next three minutes he took two numbers from the blackboard (not necessarily adjacent) and
replaced them with their sum or their product. In the end he got one number.
Unfortunately, due to the awful memory he forgot that number, but he remembers four original numbers,
sequence of the operations and his surprise because of the very small result.
Help Virat remember the forgotten number to find the smallest number that can be obtained from the original
numbers by the given sequence of operations.
Constraints:
0≤ a, b, c, d≤ 1000
0 0
Input Format:
First line contains four integers separated by space representing the the original numbers.
Second line contains three signs ('+' or '*' each) separated by space representing the sequence of the operations in
the order of performing. ("+' stands for addition, *** - multiplication)
Output Format:
Output one integer number representing the minimal result which can be obtained.
Code:
#include <bits/stdc++.h>
long longans=1e15;
deque<char>Operations(20);
if((int)a.size()==1){
ans=min(ans,a[0]);
return; }
for(int i=0;i<(int)a.size();i++){
for(int j=0;j<i;j++){
vector<long long> b;
if(Operations[id]=='+') b.push_back(a[i]+a[j]);
else b.push_back(a[i]*a[j]);
for(int k=0;k<(int)a.size();k++){
0 0
if(k!=i&& k!=j) b.push_back(a[k]);
solve(b,id+1);
int main() {
vector<long long>numbers(4);
solve(numbers,0); cout<<ans;
return 0;
0 0
INPUT OUTPUT:-
#include <iostream>
int main()
int r,s,cpool,spool;
cin>>r>>s;
cpool=3.14*r*r;
spool=s*s;
if(cpool>spool)
else
return 0;
}
#include <iostream>
int main()
int aravspeed,aaronspeed,speeddiff;
cin>>aravspeed>>aaronspeed;
if(aravspeed>aaronspeed)
speeddiff=aravspeed - aaronspeed;
else
speeddiff=aaronspeed - aravspeed;
cout<<speeddiff;
return 0;
}
#include <iostream>
int main() {
int bro1,bro2,bro3;
cin>>bro1>>bro2>>bro3;
if(bro1>bro2) {
if(bro1>bro3)
cout<<bro1;
else
cout<<bro3;
else if(bro2>bro3)
cout<<bro2;
else
cout<<bro3;
return 0;
}
#include <iostream>
int main()
int n,dig=0,rem;
cin>>n;
while(n!=0)
rem=n%10;
dig=dig*10+rem;
n/=10;
while(dig!=0)
rem=dig%10;
switch(rem)
{
case 0:
cout<<"Zero ";
break;
case 1:
cout<<"One ";
break;
case 2:
cout<<"Two ";
break;
case 3:
cout<<"Three ";
break;
case 4:
cout<<"Four ";
break;
case 5:
cout<<"Five ";
break;
case 6:
cout<<"Six ";
break;
case 7:
cout<<"Seven ";
break;
case 8:
cout<<"Eight ";
break;
case 9:
cout<<"Nine ";
break;
};
dig/=10;
return 0;
#include <iostream>
int main()
int number,num,rem,result=0;
cin>>number;
num=number;
while(num!=0) {
rem = num%10;
result+=rem*rem*rem;
num/=10;
if(result==number)
else
return 0;
#include <iostream>
int main()
int nooffamilymembers,i,j;
cin>>nooffamilymembers;
for(i=nooffamilymembers;i>0;i--)
{
for(j=0;j<i;j++)
cout<<i<<" ";
cout<<endl;
return 0;
#include <iostream>
int main()
int t,n,h,i,l=1,count;
cin>>t;
while(t--)
l=1;
count=0;
cin>>n;
for(i=1;i<=n;i++) {
cin>>h;
if(h==l) {
count+=2;
if(h>l) {
l=h;
count++;
cout<<count<<endl;
return 0;
#include <iostream>
int main()
{
int M,initialtemp,finaltemp;
float Q;
cin>>M>>initialtemp>>finaltemp;
Q=M*(finaltemp - initialtemp)*4184;
cout<<""<<Q;
return 0;
#include <iostream>
int main()
int husage,wfage,coupleavgage;
cin>>husage>>wfage;
coupleavgage=(husage+wfage)/2;
return 0;
}
#include <iostream>
int main()
int weightinearth;
cin>>weightinearth;
float weightinmoon;
weightinmoon=0.166*weightinearth;
cout<<weightinmoon;
return 0;
}
#include <iostream>
class Happiness{
public:int Meat(){
int n,a,b,max=100,sum=0;
cin>>n;
while(n--)
cin>>a>>b;
//max=b;
if(b>=max)
sum+=a*max;
// cout<<max<<endl;
// cout<<sum<<endl;
else
max=b;
sum+=a*b;
// cout<<max<<endl;
// cout<<sum<<endl;
return sum;
};
int main(){
Happiness Purchase;
cout<<Purchase.Meat();
}
#include <iostream>
#include <string.h>
#include <stdio.h>
int fun(int x) {
int s = 0;
while (x)
s += x & 1;
x >>= 1;
return s;
int main() {
if(0)
int n, i, r, t, j;
cin >> n;
scanf("%lf", &a[i][j]);
memset(b, 0, sizeof(b));
b[(1 << n) - 1] = 1;
int c = fun(i);
c = c * (c - 1) / 2;
#include <iostream>
#include<cstring>
#include<string>
class aadhaar
public:
{
if(fn.empty() || mn.empty() || ln.empty() )
cout<<"Invalid Name";
else
cout<<fn<<mn<<ln;
};
int main()
aadhaar Card;
string fn,mn,ln;
cin>>fn>>mn>>ln;
Card.NameofCitizen(fn,mn,ln);
return 0;
}
#include <iostream>
class TollBooth
public:
int cars;
float tollcollected;
TollBooth(){
cars=0;
tollcollected=0;
cars++;
tollcollected+=pay;
void nonpayingcar(){
cars++;
void display(){
cout<<cars<<endl<<tollcollected<<endl;
};
int main()
TollBooth obj;
char VehicleNo[10];
float TollAmt;
int carpassed,i;
cin>>carpassed;
for(i=0;i<carpassed;i++)
{
cin>>VehicleNo>>TollAmt;
if(TollAmt>0) obj.payingcar(TollAmt);
else obj.nonpayingcar();
obj.display();
return 0;
#include <bits/stdc++.h>
//#include<iomanip>
//#include<string>
class student
string name;
int roll;
float height,weight;
public:
student(){name="Bhagavan";roll=1593;height=172.5;weight=60.4;}
void getdata() {
cin>>name>>roll>>height>>weight;
void displaydata(){
};
int main()
student s1,s2;
s1.getdata();
s1.displaydata();
s2.displaydata();
return 0;
#include <iostream>
using namespace std;
class Friends
public:void Gifts(){
int i, n, a, b[50] = { 0 };
cin >> n;
cin >> a;
b[a] = i;
};
int main()
Friends Sharing;
Sharing.Gifts();
}
#include<bits/stdc++.h>
class Drinks{
int n,a,b,c,t,ans=0;
public:void Shop(){
cin>>n>>a>>b>>c;
void display(){
for(int i=0;i<=b;i++)
for(int j=0;j<=c;j++)
if(2*(n-i-j*2)>=0&&2*(n-i-j*2)<=a)
ans++;
cout<<ans;
};
int main(){
Drinks Buy;
Buy.Shop();
Buy.display();
}
#include <bits/stdc++.h>
class IndianArmy
public:int ResumesofCamdidates(){
long long n;
cin>>n;
cout<<k+k*(n-5)/6+k*(n-5)*(n-6)/42;
return 1;
};
int main(){
IndianArmy GroupingofResumes;
GroupingofResumes.ResumesofCamdidates();
return 0;
}
#include <iostream>
class ITEM
public:
int n;
float large=0,summ=0;
float arr[100],code[100];
n=b;
for(int i=0;i<n;i++)
cin>>code[i]>>arr[i];
void largest(){
for(int i=0;i<n;i++)
{
if(arr[i]>=large)
large=arr[i];
void sum(){
for(int i=0;i<n;i++)
summ+=arr[i];
void displayitems(){
cout<<"Largest Price="<<large<<endl;
cout<<"Sum of Prices="<<summ<<endl;
for(int i=0;i<n;i++)
};
int main()
ITEM order;
int b;
cin>>b;
order.getdata(b);
order.largest();
order.sum();
order.displayitems();
return 0;
}
#include<iostream>
class Complex{
public:
int r1,i1,r2,i2,r3,i3;
Complex(){cin>>r1>>i1;cin>>r2>>i2;}
void addcomplex(){
r3=r1+r2;
i3=i1+i2;
void displaycomplex(){
cout<<r1<<"+"<<i1<<"i"<<endl;
cout<<r2<<"+"<<i2<<"i"<<endl;
cout<<r3<<"+"<<i3<<"i"<<endl;
};
int main(){
Complex calculate;
calculate.addcomplex();
calculate.displaycomplex();
return 0;
Constructor Overloading:-
#include <iostream>
class Student
public:
cout<<name<<" "<<id<<endl;
}
cout<<name<<" "<<id<<endl;
};
int main()
Student Details;
string name;
int id;
cin>>name>>id;
Details.Identity(name,id);
cin>>id>>name;
Details.Identity(id,name);
return 0;
}
#include <iostream>
class Store{
public:
cout<<id<<endl;
cout<<totalavl - consumed<<endl;
};
int main()
Store purchase;
int id,totalavl,consumed;
cin>>id>>totalavl>>consumed;
purchase.itemcount(id);
purchase.itemcount(totalavl,consumed);
return 0;
}
#include<bits/stdc++.h>
int i,n,a,mx=INT_MIN,c[1000];
int main(){
cin>>n;
mx=res(n);
cout<<dis(n,mx);
return 0;
for(i=0;i<n;i++){
cin>>a;
c[a]++;
mx=max(mx,c[a]);
return mx;
}
return mx+1;
return mx;
if(n%mx==2)
return mx+1;
return mx;
#include <iostream>
class Hospital{
public:
cout<<mdeicinebill*days<<endl;
}
void bill(int roomrent,int days){
cout<<roomrent*days;
};
int main()
Hospital ob;
int roomrent;
cin>>mdeicinebill>>days;
ob.bill(mdeicinebill,days);
cin>>roomrent>>days;
ob.bill(roomrent,days);
return 0;
#include<bits/stdc++.h>
int i,T,a,b,c,n;
public:
void get(){
std::cin>>a>>b>>c;
n=2*abs(a-b);
void get2(){
if(c>n||max(a,b)>n)
cout<<"-1"<<endl;
else if(c>n/2)
cout<<c-n/2<<endl;
else
cout<<c+n/2<<endl;
};
int main(){
cin>>T;
solve p;
f(i,0,T){
p.get();
p.get2();
return 0;
}
#include <iostream>
class Olympic{
public:
cout<<D1+D2<<" meters"<<endl;
cout<<D3+D4+D5<<" meters"<<endl;
};
int main()
Olympic Medal;
int D1,D2,D3,D4,D5;
cin>>D1>>D2>>D3>>D4>>D5;
Medal.distance(D1,D2);
Medal.distance(D3,D4,D5);
return 0;
#include <iostream>
int main()
int t;
cin>>t;
while(t--){
int n,odd=0;
cin>>n;
int z=power(n,odd);
//cout<<n<<z;
power(n,z,1);
return 0;
}
int a[2*x];
for(int i=0;i<2*x;i++){
cin>>a[i];
if(a[i]%2==1)
p++;
return p;
if(x==y)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 1;
}
#include <iostream>
class AccBalance{
public:
AccBalance(){cout<<"Zero Balance"<<endl;}
AccBalance(int balance){
if(balance<0)
else if(balance==0)
else
};
int main()
AccBalance defltBal;
int balance;
cin>>balance;
AccBalance currBal(balance);
return 0;
}
#include <iostream>
class Country{
public:
Country(){cout<<"Country:INDIA"<<endl;}
cout<<"State:"<<statename<<endl<<"Area:"<<area<<endl<<"Density:"<<density<<endl;
};
int main()
Country country;
char statename[100];
int area,density;
cin>>statename>>area>>density;
Country statesofindia(statename,area,density);
return 0;
}
#include <iostream>
class Welcomemsg{
public:
cout<<"Hi "<<fname<<endl;
};
int main()
Welcomemsg ob;
string fname,lname;
cin>>fname;
ob.msg(fname);
cin>>fname>>lname;
ob.msg(fname,lname);
return 0;
Operator Overloading:-
#include <iostream>
class Fraction{
public:
int num,den;
num=n;
den=d;
res.num=num * obj.den;
res.den=den * obj.num;
return res;
void display1(){
cout<<num/den;
void display2(){
cout<<num<<"/"<<den;
void display3(){
cout<<"Error";
};
int main()
int a,b,c,d;
cin>>a>>b;
cin>>c>>d;
if(ob1.den==0 || ob2.den==0){
cout<<"Error";
return 0;
if(ob3.den==1)
ob3.display1();
else{
for(int i=2;i<50;i++)
ob3.num=ob3.num/i;
ob3.den=ob3.den/i;
}
ob3.display2();
return 0;
#include <iostream>
class Time
int h,m,s;
public:
Time()
cin>>h>>m>>s;
void check()
};
return true;
else
return false;
int main()
Time t1,t2;
t1.check();
t2.check();
if(t1==t2)
else
return 0;
}
#include <iostream>
class Scrum{
public:
int n;
Scrum(int h)
n=h;
--n;
return 1;
void display(){
int res=1;
for(int i=1;i<=n;i++){
res=res*i;
cout<<res;
};
int main()
int n;
cin>>n;
Scrum T(n);
T--;
T.display();
return 0;
#include<iostream>
class Fraction
public:
int num,den;
Fraction()
num=0;
den=0;
}
void getinput()
cin>>num>>den;
Fraction temp;
temp.num=(num*obj.den)+(den*obj.num);
temp.den=den*+obj.den;
return temp;
};
int main()
Fraction f1,f2,add;
f1.getinput();
f2.getinput();
add=f1+f2;
if(add.den==0)
cout<<"Error";
else if(add.num%add.den == 0)
cout<<add.num/add.den;
else
cout<<add.num<<"/"<<add.den;
return 0;
}
#include <iostream>
class matrix{
public:
int a,b,c,d;
cin>>a>>b>>c>>d;
return a*d-b*c;
};
int main()
matrix t;
cout<<~t;
return 0;
}
#include<iostream>
class Complex {
private:
public:
Complex operator+(int a) {
Complex res;
res.real = real + a;
res.imag = imag;
return res;
Complex res;
return res;
void print() { cout << real << " + " << imag <<"i"<< endl; }
};
int main()
int a,b,c;
cin>>a>>b>>c;
Complex i2 = i1 + c;
i1.print();
i2.print();
(i1+i2).print();
#include<iostream>
class compare{
public:
int first,sum1=0;
compare(int x){
first=x;
void f(){
//first1=first;
for(int i=1; i<=first/2 ; i++)
if(first%i==0)
sum1=sum1+i;
cout<<"Friendly Pair";
else
};
//main program
int main()
int first,second;
//user input
cin>>first;
//user input
cin>>second;
compare t1(first),t2(second);
t1.f();
t2.f();
t1==t2;
return 0;
}
#include <iostream>
class Diff{
public:
int n;
void getdata(){
cin>>n;
int sumofsquare();
int sumofnumsq(){
return n*(n+1)*(2*n+1)/6;
};
return n*n*(n+1)*(n+1)/4;
int main()
Diff n;
if(0)
//int sq=n*n*(n+1)*(n+1)/4;
//int sq2=n*(n+1)*(2*n+1)/6;
cout<<n.sumofsquare()-n.sumofnumsq();
return 0;
#include <iostream>
class complex
private:
float real;
float imag;
public:
complex() {cin>>real>>imag;}
complex t;
return t;
}
void output()
if(imag < 0)
else
};
int main()
c1.output();
c2.output();
(c1 - c2).output();
return 0;
#include<iostream>
class Fraction
{
public:
int num,den;
Fraction()
num=0;
den=0;
void getinput()
cin>>num>>den;
Fraction temp;
temp.num=(num*obj.den)-(den*obj.num);
temp.den=den*+obj.den;
return temp;
};
int main()
Fraction f1,f2,add;
f1.getinput();
f2.getinput();
add=f1-f2;
if(add.den==0)
cout<<"Error";
else if(add.num%add.den == 0)
cout<<add.num/add.den;
else
cout<<add.num<<"/"<<add.den;
return 0;
}
Inheritance:-
#include <iostream>
class staff{
public:
int code,speed;
string name;
void getdata();
void display();
};
void staff::getdata(){
cin>>name>>code>>speed;
void staff::display(){
cout<<"Name:"<<name<<endl<<"Code:"<<code<<endl<<"Speed"<<speed;
public:
void getdata();
void display();
};
void typist::getdata(){
cin>>name>>code>>speed;
void typist::display(){
cout<<"Name:"<<name<<endl<<"Code:"<<code<<endl<<"Speed:"<<speed;
int main()
typist t;
t.getdata();
t.display();
return 0;
#include <iostream>
using namespace std;
class Assignement{
public:
int num;
void get(){
cin>>num;
void display(){
int count=0;
while(num!=0){
count++;
num/=10;
cout<<count;
};
};
int main()
Student obj;
obj.get();
obj.display();
return 0;
}
#include <iostream>
class market{
public:
float i1,i2,i3,i4,i5;
float Subtotal,tax;
void items(){
cin>>i1>>i2>>i3>>i4>>i5;
void buy(){
Subtotal=(i1+i2+i3+i4+i5);
cout<<"Subtotal=$"<<Subtotal<<endl;
tax=0.06*i1+0.06*i2+0.06*i3+0.06*i4+0.06*i5;
cout<<"Tax=$"<<tax<<endl;
cout<<"Total=$"<<Subtotal+tax;
};
int main()
customer c;
c.items();
c.buy();
#include <iostream>
class ReceiveMesurement{
public:
int l,b;
void painingarea(){
cin>>l>>b;
cout<<l*b*27;
}
};
};
int main()
CalculateArea mt;
mt.painingarea();
return 0;
#include <iostream>
class Bank{
public:
int n;
void get(){
cin>>n;
void display(){
cout<<"500: "<<n/500<<endl;
n=n%500;
cout<<"200: "<<n/200<<endl;
n=n%200;
cout<<"100: "<<n/100<<endl;
n=n%100;
cout<<"50: "<<n/50<<endl;
n=n%50;
cout<<"10: "<<n/10<<endl;
n=n%10;
cout<<"5: "<<n/5<<endl;
n=n%5;
cout<<"1: "<<n<<endl;
};
};
int main()
CashCounting obj;
obj.get();
obj.display();
return 0;
}
#include <iostream>
class ReceiveMesurement{
public:
int l,b;
void display(){
cin>>l>>b;
cout<<"Length:"<<l<<" metres"<<endl;
cout<<"Breadth:"<<b<<" metres";
};
};
int main()
FormatMesurement mt;
mt.display();
return 0;
}
#include <bits/stdc++.h>
class graph{
public:
void edge(){
};
public:
void vertex(){
cin>>n>>m;
cout<<max(0ll,n-2*m)<<" ";
while(k*(k-1)/2<m) k++;
cout<<n-k<<endl;
};
int main()
pairs pa;
pa.edge();
pa.vertex();
return 0;
#include <iostream>
class triangle{
public:
int a,b,c;
void read(){
cin>>a>>b>>c;
void check(){
else
cout<<"NOT ISOSCELES";
};
};
int main()
isosceles obj;
obj.read();
obj.check();
return 0;
#include <iostream>
class doctor{
public:
string name,degree,pname;
int no;
void getedu(){
cin>>name>>degree>>pname;
void getdata(){
cin>>no;
void dispedu(){
void dispdata(){
cout<<"Bed Number:"<<no;
};
};
int main()
patient p;
p.getedu();
p.getdata();
p.dispedu();
p.dispdata();
return 0;
}
#include <iostream>
class teacher{
public:
int num;
void setdata(int n)
if(n==1)
num=10;
else
num=7;
void setdata2(int n)
if(n==2)
num=3;
else
num=8;
}
void tentable(){
for(int i=1;i<=10;i++)
cout<<num<<"*"<<i<<"="<<num*i<<endl;
};
};
};
};
};
int main()
int n;
cin>>n;
teacher t;
if(n==1 || n==4)
t.setdata(n);
if(n==2 || n==3)
t.setdata2(n);
t.tentable();
return 0;
class School{
public:
int roll;
string name;
};
void getdata();
void display();
};
cin>>roll>>name;
}
int main()
District obj;
School* ptr;
ptr = &obj;
return 0;
#include <bits/stdc++.h>
int a,b,c,d,i;
class Holiday{
};
public:
void Expenses(){
cin>>c;
cin>>a;
if (d<a) d=a;
b=b+a;
cout<<d*c-b;
};
Citizen obj;
obj.Expenses();
return 0;
#include <bits/stdc++.h>
using namespace std;
class Employees{
};
public:
int n;
void BuyingGame(){
cin>>n;
cout<<n - n / 2 - n / 3 - n / 5 - n / 7
+ n / 6 + n / 10 + n / 14 + n / 15 + n / 21 + n / 35
- n / 30 - n / 42 - n / 70 - n / 105 + n / 210;
};
int main()
Reward obj;
obj.BuyingGame();
return 0;
}
#include <iostream>
class Employee{
public:
int s1,s2;
};
public:
void getSalary(){
cin>>s1;
cout<<"Salary of Developer:"<<s1<<endl;
};
public:
void getSalary(){
cin>>s2;
cout<<"Salary of Driver:"<<s2<<endl;
}
};
int main()
Developer d1;
Driver d2;
d1.getSalary();
d2.getSalary();
return 0;
#include <iostream>
class consumer{
public:
string name;
};
int code;
long tel;
int quan,price;
void getdata(){
cin>>name>>code;
cin>>tel;
cin>>quan;
cin>>price;
void display(){
};
int main()
consumer* o1;
transaction o2;
o1=&o2;
o1->getdata();
o1->display();
return 0;
}
#include<iostream>
class Problem {
};
public:
int n,k,i;
void Divisor(){
cin>>n>>k;
int Display()
int count;
for(i=1;i<=n;++i)
if(n%i==0)
count++;
if(count==k){
cout<<i;
return 1;
cout<<-1;
return 1;
};
int main()
Calculation obj;
obj.Divisor();
obj.Display();
return 0;
#include <iostream>
using namespace std;
class Gift {
};
public:
int a[10],n;
void Cubes(){
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n/2;i+=2)
/*int temp=a[i];
a[i]=a[n-i-1];
a[n-i-1]=temp;*/
swap(a[i],a[n-i-1]);
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
};
int main()
Birthday obj;
obj.Cubes();
return 0;
}
#include <iostream>
#include<string>
class Decode{
};
public:
string s1,s2;
int n;
void Convert(){
cin>>n>>s1;
for(int i=0;i<n;i++){
if((n-i)%2==1)
s2=s2+s1[i];
else
s2=s1[i]+s2;
cout<<s2;
}
};
int main()
Word obj;
obj.Convert();
#include <iostream>
class country
public:
};
{
public:
char a[20];
int b,c;
char d[20];
int e,f;
void getdata(){
cin>>a>>b>>c>>d>>e>>f;
void display()
};
int main() {
if(0)
cout<<"country::getdata();";
country *o1;
state o2;
o1=&o2;
o1->getdata();
o2.display();
return 0;
}
#include<iostream>
class Smartphone{
};
public:
int T,S,q,c=0;
void Listening(){
cin>>T>>S>>q;
while(S<T){
c++;
S*=q;
cout<<c;
};
int main()
{
LoveForMusic obj;
obj.Listening();
return 0;
Templates:-
#include <bits/stdc++.h>
if(a>b)
cout<<"Kayal\n";
else
cout<<"Elavenil\n";
return 1;
int main()
int a,b;
cin>>a>>b;
if(a%(a-b)==0 && b%(a-b)==0)
cout<<"Equal\n";
else
Visit(a,b);
return 0;
#include <iostream>
t = t*k*n/100.0;
while(n--){
cout<<min(t,k)<<" ";
t-=min(t,k);
return 1;
int main()
{
int n,k,t;
cin>>n>>k>>t;
Bar(n,k,t);
return 0;
#include <iostream>
cout<<player2<<" "<<player1;
int main()
string player1,player2;
cin>>player1>>player2;
InterchangeFavPlayers(player1,player2);
return 0;
}
#include <iostream>
#include<cmath>
int c;
c=sqrt(x*x+y*y);
if(c*c==x*x+y*y){
cout<<"black\n";
return 0;
if(x*y<0)
c++;
if(c%2==0)
cout<<"black";
else cout<<"white";
return 1;
int main()
{
int x,y;
cin>>x>>y;
MagicClocl(x,y);
return 0;
#include <iostream>
cout<<((b+c-1)/c)*((a+c-1)/c);
return 1;
int main()
int a,b,c;
cin>>a>>b>>c;
Rome(a,b,c);
return 0;
}
#include <iostream>
if(T%2==0)
return 4*T+1;
else if(T%4==1)
return 2*T+1;
else
return T+1;
int main()
int T,n;
cin>>T;
while(T--){
cin>>n;
cout<<Square(n)<<endl;
return 0;
}
#include <iostream>
int c=0;
for(int i=0;i<=d;i++){
if(i%k==0||i%l==0||i%m==0||i%n==0)
c++;
return c-1;
int main()
int k,l,m,n,d;
cin>>k>>l>>m>>n>>d;
cout<<Counting(k,l,m,n,d);
return 0;
}
#include <iostream>
if(x1==x2 || y1 == y2 || z1==z2)
cout<<"YES";
else
cout<<"NO";
return 1;
int main()
int x1,y1,z1,x2,y2,z2;
cin>>x1>>y1>>z1>>x2>>y2>>z2;
Planet(x1,y1,z1,x2,y2,z2);
return 0;
}
#include<bits/stdc++.h>
int d=1,e,i,j;
for(i=0;i<=4000;i++)
for(j=0;j<=4000;j++) {
e=n-a*i-b*j;
if(e>=0&&e%c==0)
d=max(d,i+j+e/c);
cout<<d;
return 1;
int main(){
int n,a,b,c;
cin>>n>>a>>b>>c;
Pieces(n,a,b,c);
}
#include <iostream>
template<class T>
T DivideMangosteen(T PurchasedWeight){
if(PurchasedWeight%2==0)
cout<<"YES";
else
cout<<"NO";
return 1;
int main()
int PurchasedWeight;
cin>>PurchasedWeight;
DivideMangosteen(PurchasedWeight);
return 0;
Exceptional Handling:-
#include <iostream>
int main()
string str1,str2;
try{
cin>>str1>>str2;
if(cin){
for(int i=0;i<n;i++){
throw 0;
if(str1[i]==str2[i])
count++;
if(count!=n)
else
cout<<str1<<" is "<<str2;
cout<<"Inappropriate Input";
}
return 0;
#include <bits/stdc++.h>
#include <string.h>
int main()
int k;
try{
cin>>k;
if(cin)
cout<<fixed<<setprecision(0)<<tgamma(k+1);
else
throw "e";
return 0;
#include <iostream>
int main()
int n,m;
try{
cin>>n;
cin>>m;
if(cin){
cout<<n-1+(1+2*(n-1))*(m-1);
else
throw 0;
catch(int griddimensions)
}
return 0;
#include<bits/stdc++.h>
int main()
float hour,salaryperday;
try{
cin>>hour;
cin>>salaryperday;
if(cin){
cout<<fixed<<setprecision(2)<<hour*salaryperday;
else
throw 0;
catch(int workstatus)
return 0;
}
#include <iostream>
int main()
int donuts,milk;
try{
cin>>donuts;
cin>>milk;
if(milk==0)
throw donuts;
else
catch(int e){
return 0;
}
#include <iostream>
#include <math.h>
int main()
int a;
try {
cin>>a;
cout<<"Valid Mark";
else
throw "e";
cout<<"Invalid Mark";
}
#include <bits/stdc++.h>
int main()
int unitconsumed,costperunit;
try{
cin>>unitconsumed;
cin>>costperunit;
res=pow(unitconsumed,costperunit);
if(cin){
cout<<res;
else
throw 0;
catch(int unit){
cout<<"Incomplete Data";
return 0;
}
#include <iostream>
int main()
int n,m,a;
try{
cin>>n>>m>>a;
if(cin){
cout<<((n+a-1)/a)*((m+a-1)/a);
else
throw 0;
catch(int dimension){
cout<<"Invalid Dimension";
return 0;
}
#include<bits/stdc++.h>
int main(){
int t,i,j;
cin>>t;
string str;
f(j,0,t){
f(i,0,2){
try{
cin>>str[i];
if(isalpha(str[i]))
cout<<str[i]<<" is alphabetic"<<endl;
else
throw str[i];
}
#include <iostream>
int main()
int a,b,c;
try{
cin>>a>>b>>c;
if(cin){
cout<<2*(a*b+b*c+c*a);
else
throw 0;
catch(int objectinfo){
return 0;
}
STL:-
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
int N, a, b;
while (cin>>N) {
vector<pair<int,pair<int,int>>>StorageDrives;
cin>>a>>b;
sort(StorageDrives.begin(),StorageDrives.end());
int z=StorageDrives.size();
cap = StorageDrives[i].second.first;
#include<bits/stdc++.h>
int n,m,sx=99999,sy=99999,x,y;
char a[55][55];
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
if(a[i][j]=='*'){
x=max(x,i),y=max(y,j),sx=min(sx,i),sy=min(sy,j);
}
}
for(int i=sx;i<=x;i++){
cout<<endl;
return 0;
cout<<"vector<vector<char>>drawing(n,vector<char>(m,'0')); drawing[row][col]";
#include <bits/stdc++.h>
LL n, k, v, idx;
string name[N];
int main(){
LL t; cin>>t; while(t--){
cin>>n>>k>>v;
cin>>name[i];
LL st=((v-1)*k)%n;
//cout<<"Case #"<<(++idx)<<":";
vector<int> ans;
ans.push_back((st+i)%n);
sort(ans.begin(), ans.end());
cout<<name[id]<<" ";
cout<<"\n";
return 0;
#include <bits/stdc++.h>
int main()
int n;
cin>>n;
set<pair<string,string>>Descriptionofleaves;
string species,color;
while(n--){
cin>>species>>color;
Descriptionofleaves.insert(make_pair(species,color));
cout<<Descriptionofleaves.size();
return 0;
#include <bits/stdc++.h>
void sum(){}
int n,m;
int cost[2020];
string g[1010];
int main()
cin>>n>>m;
for(int i=0;i<n;i++)
cin>>g[i];
for(int j=0;j<m;j++)
{
if(g[i][j]=='#')
use[i].push_back(j+n);
use[j+n].push_back(i);
queue<int>BankChamber;
BankChamber.push(n-1);
cost[n-1]=1;
while(!BankChamber.empty())
int t=BankChamber.front();
BankChamber.pop();
int z=use[t].size();
for(int i=0;i<z;i++)
if(cost[use[t][i]]==0)
cost[use[t][i]]=cost[t]+1;
BankChamber.push(use[t][i]);
cout<<cost[0]-1<<endl;
sum();
return 0;
cout<<"BankChamber.push(n);";
}
#include<bits/stdc++.h>
ll a[100006],c[3];
int main()
ll n,m,i,j,k,l,sum=0;
cin>>n>>m;
for(i=0;i<m;i++)
sum=0;
for(j=0;j<3;j++)
cin>>c[j];
sum=sum+a[c[j]];
l=1;
for(k=0;k<3;k++)
if(l==sum)
l++;
if(a[c[k]]==0)
{
a[c[k]]=l++;
for(i=1;i<=n;i++)
cout<<a[i]<<" ";
return 0;
cout<<"map<int,int>dance; set<int>dancer;";}
#include <bits/stdc++.h>
int main(){
int t;
cin >> t;
while (t--) {
int n, d;
map<ll, vector<pair<long,long>>>TGS;
TGS[day].push_back({sad, lec}); }
priority_queue<pair<long,long>>PQ;
PQ.push(x);
if (!PQ.empty())
PQ.pop();
p.second--;
if (p.second == 0) {}
else
PQ.push({p.first, p.second});
ll cnt = 0;
while (!PQ.empty()) {
PQ.pop();
return 0;
deque<char>Operations(20);
if((int)a.size()==1){
ans=min(ans,a[0]);
return;
for(int i=0;i<(int)a.size();i++){
for(int j=0;j<i;j++){
vector<long long> b;
if(Operations[id]=='+') b.push_back(a[i]+a[j]);
else b.push_back(a[i]*a[j]);
for(int k=0;k<(int)a.size();k++){
solve(b,id+1);
}
int main() {
vector<long long>numbers(4);
solve(numbers,0);
cout<<ans;
return 0;
#include <bits/stdc++.h>
int i,j,n,x[110],d[110];
int main(){
cin>>n;
f(i,1,n+1) cin>>x[i]>>d[i];
f(i,1,n+1){
f(j,i+1,n+1){
return 0;
}
}
return 0;
#include<bits/stdc++.h>
int i,n;
string s,t,u;
int D()
for(i=0;s[i];i++)if(s[i]^t[i])return 0;
return 1;
int main()
for(cin>>s>>n;n--;)
cin>>t;
if(D()&&(u.empty()||t<u))u=t;
}
if(u.empty())cout<<s;
else cout<<u;
return 0;
Advanced Inheritance:-
#include <iostream>
class Employee{
public:
};
public:
int code,basic,hra,da,pf,total;
string name,position;
void getEmpDetails(){
cin>>code>>name>>position;
void getPayDetails(){
cin>>basic>>hra>>da>>pf;
void calculate(){
total=basic+hra+da-pf;
void display(){
cout<<"Employee Number:"<<code<<endl;
cout<<"Employee Name:"<<name<<endl;
cout<<"Employee Role:"<<position<<endl;
};
int main()
Salary s;
s.getEmpDetails();
s.getPayDetails();
s.calculate();
s.display();
return 0;
}
#include <iostream>
class Person{
};
};
public:
int id;
string name,group,staff;
void accept_instructor_details(){
cin>>id>>name>>group>>staff;
void display_instructor_details(){
cout<<"Id:"<<id<<endl;
cout<<"Name:"<<name<<endl;
cout<<"Group:"<<group<<endl;
cout<<"Staff:"<<staff<<endl;
};
int main()
int n;
cin>>n;
Instructor inst[n];
for(int i=0;i<n;i++){
inst[i].accept_instructor_details();
inst[i].display_instructor_details();
return 0;
cout<<"Instructor *inst;";
#include <iostream>
class acc{
public:
int no;
void getacc(){
cin>>no;
};
public:
string name;
int code;
void getbranch(){
cin>>name>>code;
void display(){
cout<<"Acc No:"<<no<<endl;
cout<<"Name:"<<name<<endl;
cout<<"Branch Code:"<<code<<endl;
};
int main()
branch b;
b.getacc();
b.getbranch();
b.display();
return 0;
#include <iostream>
class Food{
};
class Nutritionist:public Food{
};
public:
float cal,fat;
void calorie(){
cin>>cal>>fat;
void dplan(){
if(cal<fat)
};
int main()
Patient p;
p.calorie();
p.dplan();
return 0;
#include <iostream>
using namespace std;
class Sam{
};
public:
int rows;
rows=y;
void display(){
for(int i=0;i<rows;i++){
for(int j=0;j<rows;j++){
cout<<"* ";
cout<<endl;
};
int main()
Robin obj;
int y;
cin>>y;
obj.read(y);
obj.display();
return 0;
}
#include <iostream>
class student{
public:
int roll,m1,m2;
void get(){
cin>>roll>>m1>>m2;
};
class sports{
public:
int sp;
void getsm(){
cin>>sp;
};
public:
void display(){
cout<<"Roll No:"<<roll<<endl;
cout<<"Total:"<<m1+m2+sp<<endl;
cout<<"Average:"<<(m1+m2+sp)/3<<endl;
}
};
int main()
statement obj;
obj.get();
obj.getsm();
obj.display();
return 0;
#include <iostream>
class Shape{
public:
int len,wid;
len=l;
wid=b;
};
public:
void output(){
cout<<len*wid<<endl;
};
public:
void output(){
//if((len*wid)%2==0)
cout<<0.5*len*wid<<endl;
//else
//cout<<len*wid/2+1<<endl;
};
int main()
int l,b;
cin>>l>>b;
Rectangle rect;
Triangle tri;
rect.input(l,b);
tri.input(l,b);
rect.output();
tri.output();
return 0;
}
#include <iostream>
class customer{
public:
int no;
string name;
void acceptc(){
cin>>name>>mobile>>no;
};
public:
int bal;
void acceptd(){
cin>>bal;
void dispd(){
cout<<"Customer Name:"<<name<<endl;
cout<<"Balance:"<<bal<<endl;
}
};
public:
void acceptb(){
cin>>loan_no>>amt;
void dispb(){
cout<<"Loan No:"<<loan_no<<endl;
cout<<"Loan Amount:"<<amt<<endl;
};
int main()
int n;
cin>>n;
borrow b1[n];
for(int i=0;i<n;i++){
b1[i].acceptc();
b1[i].acceptd();
b1[i].acceptb();
b1[i].dispd();
b1[i].dispb();
return 0;
}
#include <iostream>
class Receive{
public:
int r1,i1,r2,i2,r3,i3;
void getdata(){
cin>>r1>>i1>>r2>>i2;
};
public:
void add(){
r3=r1+r2;
i3=i1+i2;
};
public:
void output(){
cout<<r1<<"+"<<i1<<"i"<<endl;
cout<<r2<<"+"<<i2<<"i"<<endl;
cout<<r3<<"+"<<i3<<"i"<<endl;
}
};
int main()
Present calc;
calc.getdata();
calc.add();
calc.output();
return 0;
#include <iostream>
class Person{
};
};
public:
int n1,n2,basic,hra,da,pf;
string name1,role1,col,ifsc,name2,role2;
void getdetail(){
cin>>n1>>name1>>role1>>col>>ifsc>>n2>>name2>>role2;
}
void getEmployeeDetails(){
cin>>basic>>hra>>da>>pf;
void student_display(){
cout<<"Person number:"<<n1<<endl;
cout<<"Person name:"<<name1<<endl;
cout<<"Person Role:"<<role1<<endl;
cout<<"Student IFSC:"<<ifsc<<endl;
cout<<"Person number:"<<n2<<endl;
cout<<"Person name:"<<name2<<endl;
cout<<"Person Role:"<<role2<<endl;
void employee_display(){
cout<<"Employee HRA:"<<hra<<endl;
cout<<"Employee DA:"<<da<<endl;
cout<<"Employee PF:"<<pf<<endl;
};
int main()
Student e;
e.getdetail();
e.getEmployeeDetails();
e.student_display();
e.employee_display();
return 0;
cout<<"s.student_display();";
}
lOMoARcPSD|22435646
Object Oriented Design And Programming (SRM Institute of Science and Technology)
I/O operation:
case 0:
cout<<"Zero ";
break;
} n=n/10; } }
2. Dhoni’s daughter Ziva
#include <iostream>
using namespace std;
int main()
{
int weightinearth;
float weightinmoon;
cin>>weightinearth;
weightinmoon = weightinearth*16.6/100;
cout<<weightinmoon;
return 0;
}
4. Johan’s teacher
#include <iostream>
using namespace std;
int main()
{
int fannumber;
cin>>fannumber;
if (fannumber>7)
cout<<"Fan of Dhoni";
else if (fannumber==7)
return 0;
}
7. Professor JD
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
float b,leftside,rs1,rs2;
cin>>b>>leftside;
rs1=leftside*leftside+b*b;
rs2=leftside*leftside-b*b;
cout<<fixed;
cout<<setprecision(5);
cout<<sqrt(rs2)<<" "<<sqrt(rs1);
return 0;
}
sumofangles=angle1+angle2+angle3;
if(sumofangles==180)
cout<<"Angles are valid";
else
cout<<"Angles are not valid";
return 0;
}
int acc;
double balance;
public:
void initial()
{ std::cin>>name>>acc>>accounttype>>balance; }
void deposit()
{ float deposit;
cin>>deposit;
balance+=deposit; }
void withdraw() { float withdraw;
cin>>withdraw;
if(withdraw>balance){ cout<<"Insufficient Balance\n";}
else balance-=withdraw; }
void disp() {
cout<<"NAME="<<name<<"\nACCNO="<<acc<<"\nTYPE="<<accounttype<<"\nBALANCE
AMOUNT="<<balance<<endl; }
};
int main()
{float deposit(),withdraw();
Bank obj;
obj.initial();
obj.deposit();
obj.withdraw();
obj.disp();
return 0;
}
class house
{
char housename[30];
address a;
int n;
public:
void input();
};
void house::input()
{
cin>>housename;
cout<<"House name="<<housename<<endl;
a.getad();
a.putad();
cin>>n;
int lenght,widht,height;
for (int i = 0; i < n; i++)
{
cin>>lenght>>widht>>height;
cout<<"Detail of Room "<<i+1<<endl;
cout<<"Length="<<lenght<<endl;
cout<<"Breadth="<<widht<<endl;
cout<<"Height="<<height<<endl;
}
}
int main() {
if(0)
{
cout<<"void house::display()";
}
house x;
x.input();
return 0;
}
cout<<fixed<<setprecision(0)<<k;
return 0;
}
};
int main()
{ IndianArmy GroupingofResumes;
GroupingofResumes.ResumesofCamdidates();
return 0;
}
int main()
{
LoveForMusic Learning;
Learning.Instruments();
return 0;
}
};
int main() {
HiddenTime LatestTime;
LatestTime.in();
LatestTime.maximumTime();
LatestTime.out();
cout<<endl;
return 0;
}
class catanddog
{public:
int c,d,l,t;
void count()
{
cin>>t;
while(t--){
cin>>c>>d>>l;
long int u=l-4*d;
if(u<0||(u%4!=0)||u>4*c)
cout<<"no";
else cout<<"yes";
cout<<endl;
}
}
};
int main()
{
catanddog pets;
pets.count();
return 0;
}
void totalMoney(int n)
{
int r;
r = n%7;
n/=7;
total =(n*(49+(7*n)))/2 + r*(2*(n+1)+r-1)/2;
cout<<total;
}
};
int main(){
int n;
cin>>n;
Bank CalculateMoney;
CalculateMoney.totalMoney(n);
return 0;
}
}
}
};
int main()
{
Building construction;
construction.calculateCost();
construction.determineSuitability();
return 0;
}
1. Highway 201
#include <iostream>
using namespace std;
void union_sets(int a){
cout<<"1";
}
void union_sets(int a,int b){
cout<<"2";
}
int find_set(int v){
return 0;
}
int main(){
int x;
cin>>x;
while(x--) {
long long n,a,s=0;
cin>>n;
for(int i=0; i<n; s+=a,i++)
cin>>a;
cout<<(s%n)*(n-(s%n))<<endl;
}
return 0;
}
{
int u,v;cin>>u>>v;if(u>v) swap(u,v);
vis[u]++;if(vis[u]==1) anss--;
}
cin>>q;int op,u,v;
while(q--)
{
cin>>op;
if(op==3)cout<<anss<<'\n';
else if(op==1)
{
cin>>u>>v;if(u>v) swap(u,v);
vis[u]++;if(vis[u]==1) anss--;
}else {
cin>>u>>v;if(u>v) swap(u,v);
vis[u]--;if(vis[u]==0) anss++;
}
}return 0;
cout<<"void change(int u) void change(int u,int v)";
}
3. Ram is an athelet
#include <iostream>
using namespace std;
class Olympic{
public:
void distance(int d1, int d2){
cout<<d1+d2<<" meters"<<endl;
}
void distance(int d3, int d4, int d5){
cout<<d3+d4+d5<<" meters";
}
};
int main()
{
int D1,D2,D3,D4,D5;
cin>>D1>>D2>>D3>>D4>>D5;
Olympic Medal;
Medal.distance(D1,D2);
Medal.distance(D3,D4,D5);
return 0;
}
4. Rajesh Kumar
#include<bits/stdc++.h>
using namespace std;
int i,T,a,b,c,n;
#define f(i,a,n) for(i=a;i<n;i++)
class solve{
public:
void get(){
std::cin>>a>>b>>c;
n=2*abs(a-b);
}
void get2(){
if(c>n||max(a,b)>n)
cout<<"-1"<<endl;
else if(c>n/2)
cout<<c-n/2<<endl;
else
cout<<c+n/2<<endl;
}
};
int main(){
cin>>T;
solve p;
f(i,0,T){
p.get();
p.get2();
}
return 0;
cout<<"void pline(int v[],int n) void pline(int v) else if(x>n||x<=0)";
}
if(a[i]%2==1)
p++;
}
return p;
}
int power(int x,int y,int p){
if(x==y)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 1;
}
6. Sarvana stores
#include<iostream>
using namespace std;
class Salary
{
public:
void Increment(int cursal)
{
cout<<cursal<<endl;
}
void Increment(int cursal ,int bonus)
{
cout<<cursal+bonus;
}
};
int main()
{
int cursal,bonus;
cin>>cursal>>cursal>>bonus;
Salary empsal;
empsal.Increment(cursal);
empsal.Increment(cursal,bonus);
return 0;
}
}
int msg(char fstname[100],char lstname[100])
{
cout<<"Welcome "<<fstname<<" "<<lstname<<endl;
return 0;
}
};
int main()
{Welcomemsg ob;
char fname[100], fname2[100], lname[100];
cin>>fname>>fname2>>lname;
ob.msg(fname);
ob.msg(fname,lname);
return 0;
}
8. Idlyzone in jeeva’s
#include <bits/stdc++.h>
#define T int
using namespace std;
void debug(T v[],int m){
}
void debug(vector<T>v)
{}
int main()
{
int t;
cin>>t;
while(t--) {
long long n;
cin>>n;
if(n%2==1){}
cout << max(6LL, n+1) / 2*5 <<'\n';
}
}
cout<<fixed<<setprecision(1)<<(double)S*a/f<<"
"<<fixed<<setprecision(1)<<(double)S*b/f<<"
"<<fixed<<setprecision(1)<<(double)S*c/f<<endl;
return 0;
cout<<"Solve(b,c,y,z);void Solve(int a,double &x){} void Solve(int a,int b,double &x,double
&y){}";
}
return 0;
}
Operator Overloading:
1. The wonderking
#include<iostream>
using namespace std;
class compare{
public:
int first,sum1=0;
compare(int x){
first=x;
}
void f(){
//first1=first;
for(int i=1; i<=first/2 ; i++)
{
//finding and adding divisors of first number
if(first%i==0)
sum1=sum1+i;
}
}
void operator ==(compare t2){
if(first==t2.sum1 && t2.first==sum1)
cout<<"Friendly Pair";
else
cout<<"Not a Friendly Pair";
}
};
//main program
int main()
{
int first,second;
//user input
cin>>first;
//user input
cin>>second;
compare t1(first),t2(second);
t1.f();
t2.f();
t1==t2;
return 0;
}
class Scrum
private:
int n;
public:
void get(){
cin>>n;
int operator -- ()
return n--;
void fac(){
int fact=1;
for(int i=2;i<=n;i++){
fact*=i;}
cout<<fact;
};
int main()
Scrum a;
a.get();
--a;
a.fac();
return 0;
public:
int a;
Stadium(){cin>>a;}
Stadium operator - (Stadium obj2)
{Stadium s3;
s3.a = (a > obj2.a) ? a : obj2.a;
do
{
if (s3.a % a == 0 && s3.a % obj2.a == 0)
{
return s3;
break;
}
else
++s3.a;
} while (true);
}
};
int main()
{
Stadium s1,s2;
Stadium();
Stadium s3=s1-s2;
cout<<s3.a;
return 0;
}
ex.real=real+a;
ex.img=img;
return ex;
}
Complex operator+(Complex obj){
Complex ex;
ex.real=real+obj.real;
ex.img=img+obj.img;
return ex;
}
void print(){
cout<<real<<" + "<<img<<"i"<<endl;
}
};
int main()
{
Complex i1,i2;
int a,b,c;
cin>>a>>b>>c;
i1.real=a;
i1.img=b;
i2.real=a+c;
i2.img=b;
i1.print();
(i1+c).print();
(i1+i2).print();
return 0;
}
Event obj3=obj1+obj2;
cout<<obj3.a;
return 0;
}
num = n;
deno = d;
}
Fraction operator +(Fraction f)
{
int n = num*f.deno+f.num*deno;
int d = deno*f.deno;
return Fraction(n/gcd(n,d),d/gcd(n,d));
}
class matrix{
public:
int operator ~(){
int a,b,c,d;
cin>>a>>b>>c>>d;
return a*d-b*c;
}
};
int main()
{
matrix t;
cout<<~t;
return 0;
}
Inheritance:
public:
int num;
void setdata(int n)
{
if(n==1)
num=10;
else
num=7;
}
void setdata2(int n)
{
if(n==2)
num=3;
else
num=8;
}
void tentable(){
for(int i=1;i<=10;i++)
cout<<num<<"*"<<i<<"="<<num*i<<endl;
}
};
class ten:public teacher{
};
class three:public teacher{
};
class eight:public teacher{
};
class seven:public teacher{
};
int main()
{
int n;
cin>>n;
teacher t;
if(n==1 || n==4)
t.setdata(n);
if(n==2 || n==3)
t.setdata2(n);
t.tentable();
return 0;
}
public:
int a,b;
Shape(){cin>>a>>b;}
};
class PaintCost
{
public:
int cost;
PaintCost(){cost=70;}
};
class Rectangle:public Shape,public PaintCost
{
public:
Rectangle(){cout<<"Total area:"<<a*b<<endl;
cout<<"Total paint cost:$"<<cost*a*b;}
};
int main()
{
Rectangle Rect;
return 0;
}
5. Gokul is going
#include <iostream>
using namespace std;
class Time
{public:
int h,m,s;
};
class addTime : public Time
{public:
void intime(){cin>>h>>m>>s;}
void outtime(){cout<<h<<':'<<m<<':'<<s;}
};
int main()
{
addTime T;
T.intime();
T.outtime();
return 0;
}
7. Rohan is planning
#include <iostream>
using namespace std;
class ReceiveMesurement
{
public:
long l,b;
};
class CalculateArea : public ReceiveMesurement
{
public:
CalculateArea(){cin>>l>>b;}
void painingarea(){cout<<27*l*b;}
};
int main()
{
CalculateArea mt;
mt.painingarea();
return 0;
}
8. Shalini is a designer
#include <iostream>
using namespace std;
class ReceiveMesurement{
public:
int x,y;
void input(){
cin>>x>>y;
}
};
class CalculatePerimeter : public ReceiveMesurement{
public:
void perimeter(){
cout<<2*(x+y);
}
};
int main()
{ CalculatePerimeter mt;
mt.input();
mt.perimeter();
return 0;
}
void print(){}
};
int main()
{ Result r;
r.accept();
r.check();
r.print();
return 0;
}
};
class arbitrary:public passPal
{
public:
string s;
void goal(){cin>>n>>s;}
void count()
{sort(s.begin(),s.end());
cout<<s;}
}obj;
int main()
{
obj.goal();
obj.count();
return 0;
}
#include <iostream>
#include<string>
using namespace std;
class Decode{
public:virtual void Convert()=0;
};
class Word:public Decode{
public:
string s1,s2;
int n;
void Convert(){
cin>>n>>s1;
for(int i=0;i<n;i++){
if((n-i)%2==1)
s2=s2+s1[i];
else
s2=s1[i]+s2;
}
cout<<s2;
}
};
int main()
{
Word obj;
obj.Convert();
}
obj.Listening();
return 0;
}
}
};
int main()
{
Reward obj;
obj.BuyingGame();
return 0;
}
6. Ravindran is working in a
#include <iostream>
using namespace std;
class Employee{
public:
int s1,s2;
};
class Developer : public Employee{
public:
void getSalary(){
cin>>s1;
cout<<"Salary of Developer:"<<s1<<endl;
}
};
class Driver : public Employee{
public:
void getSalary(){
cin>>s2;
cout<<"Salary of Driver:"<<s2<<endl;
}
};
int main()
{
Developer d1;
Driver d2;
d1.getSalary();
d2.getSalary();
return 0;
}
8. Eswar is working
#include <iostream>
using namespace std;
class country
{
public:
virtual void getdata() = 0;
virtual void display() = 0;
};
class state:public country
{
public:
char a[20];
int b,c;
char d[20];
int e,f;
void getdata(){
cin>>a>>b>>c>>d>>e>>f;
}
void display()
{
cout<<"Country:"<<a<<endl<<"Country's Polio %:"<<b<<endl;
cout<<"Country Literacy %:"<<c<<endl<<"Interdependency Rate:"<<(float)b/c<<endl;
cout<<"State Name:"<<d<<endl<<"% of Polio of State:"<<e<<endl;
cout<<"% of Literacy of State:"<<f<<endl<<"Interdependency Rate:"<<(float)e/f;
}
};
int main() {
if(0)
cout<<"country::getdata();";
country *o1;
state o2;
o1=&o2;
o1->getdata();
o2.display();
return 0;
}
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
}
};
int main()
{
Birthday obj;
obj.Cubes();
return 0;
}
Tamplets:
1. Afghan President
#include <bits/stdc++.h>
#include<fstream>
#include<string.h>
using namespace std;
unsigned char str[105][105], c[5];
int n,m;
int col[256];
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
int main()
{
cin >>n>>m>>c;
for(int i=1;i<=n;i++)
scanf("%s",str[i]+1);
for(int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
for (int k=0;k<4;k++)
if(str[i + dx[k]][j + dy[k]] == c[0])
col[str[i][j]] = 1;
int ret = 0;
for(int i=0; i<256; i++)
{
if(i == c[0] ||i == '.')
continue;
ret += col[i];
}
printf("%d",ret);
return 0;
cout<<"template<class T>";
cout<<"T find(T x,T y)";
}
2. Rohan is interested
#include <iostream>
using namespace std;
template <class Universe>
Universe Planet (Universe x1,Universe y1,Universe z1,Universe x2,Universe y2,Universe z2){
if(x1==x2 || y1 == y2 || z1==z2)
cout<<"YES";
else
cout<<"NO";
return 1;
}
int main()
{
int x1,y1,z1,x2,y2,z2;
cin>>x1>>y1>>z1>>x2>>y2>>z2;
Planet(x1,y1,z1,x2,y2,z2);
return 0;
}
3. The owner of famous farm land
#include <iostream>
using namespace std;
const int I=0x3f3f3f3f;
template <class Cow>
Cow Moves(Cow n){
Moves(n);
}
int main() {
int a,b,c,d,x,y,n;
a=b=c=d=-I;
cin>>n;
while(n--){
cin>>x>>y;
a=max(a,x+y);
b=max(b,x-y);
c=max(c,y-x);
d=max(d,-x-y);
}
cout<<a+b+c+d+4;return 0;
}
int main()
{
int numofjavelin,priceofavelin;
cin>>numofjavelin>>priceofavelin;
cout<<Javelin(numofjavelin,priceofavelin);
return 0;
}
return 1;
}
using namespace std;
int main()
{
int x,y;
cin>>x>>y;
MagicClocl(x,y);
return 0;
}
Exceptional handling
case '*':cout<<op1<<"*"<<op2<<"="<<op1*op2;
break;
case '/':cout<<op1<<"/"<<op2<<"="<<op1/op2;
break;
default: throw "Operation Error & is not a valid operator";
break;
}
}
catch(char const* a){
cout<<a;
}
return 0;
}
#include <string.h>
using namespace std;
int main()
{
int k;
try{
cin>>k;
if(cin)
cout<<fixed<<setprecision(0)<<tgamma(k+1);
else
throw "e";
}
catch (int i){
}
catch(const char *exp){
cout<<"Input should be a Integer";
}
return 0;
}
STL:
1. Nandhan is a busy
#include<bits/stdc++.h>
using namespace std;
int i,n;
string s,t,u;
int D()
{
for(i=0;s[i];i++)if(s[i]^t[i])return 0;
return 1;
}
int main()
{
for(cin>>s>>n;n--;)
{
cin>>t;
if(D()&&(u.empty()||t<u))u=t;
}
if(u.empty())cout<<s;
else cout<<u;
return 0;
cout<<"unordered_map<string,string>website; map<string,bool>searchlist; cin>>n;";
}
cout<<"map<int,set<int>>Teeth;"<<"Teeth[r].insert(c);"<<"map<int,set<int>>::iterator
consume"<<endl;
3. Winter in spain
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
set<pair<string,string>>Descriptionofleaves;
string species,color;
while(n--){
cin>>species>>color;
Descriptionofleaves.insert(make_pair(species,color));
}
cout<<Descriptionofleaves.size();
return 0;
}
int main(){
cin>>n;
for(i=0;i<n;i++) cin>>a[i];
for(i=0;i<n;i++) cin>>b[i];
for(i=0;i<n;i++){
if(a[i]!=b[i]){
for(j=i+1;j<n;j++){
if(a[i]==b[j])break;
}
while(i!=j){
swap(b[j],b[j-1]);
an[k][0]=j;
an[k][1]=j+1;
k++;j--;
}
}
}cout<<k<<endl;
for(i=0;i<k;i++)cout<<an[i][0]<<" "<<an[i][1]<<endl;
return 0;
cout<<"queue<pair<int,int>>Students;"<<"Students.front().first"<<"Students.front().second"
<<endl;
cout<<"Students.empty()"<<"Students.push"<<"Students.pop();";
}
6. Sivan is interested
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
pair<pair<int,int>,int>card[N];
stack<pair<int,int>>arrangement;
int ans[N];
int main()
{
int n;
scanf("%d",&n);
for(int i=1,x,h;i<=n;i++) scanf("%d %d",&x,&h),card[i] = {{x,h},i};
sort(card+1,card+n+1);
for(int i=n;i>=1;i--)
{
int s = 0;
while(!arrangement.empty()&&card[i].first.first+card[i].first.second-
1>=arrangement.top().first) s+=arrangement.top().second,arrangement.pop();
arrangement.push({card[i].first.first,s+1});
ans[card[i].second] = s+1;
}
for(int i=1;i<=n;i++) printf("%d ",ans[i]);
return 0;
int main() {
int N, a, b;
while (cin>>N) {
vector<pair<int,pair<int,int>>>StorageDrives;
for (int i = 0; i < N; i++) {
cin>>a>>b;
StorageDrives.push_back(make_pair((b>a) ? a : 2000000001-b, make_pair(a, b)));
}
int main(){
return 0;
}
Advance Inheritance:
1. Sivakumar is working
#include <iostream>
using namespace std;
class Person{
};
class Teaching : public Person{
};
class Instructor : public Teaching{
public:
int id;
string name,group,staff;
void accept_instructor_details(){
cin>>id>>name>>group>>staff;
}
void display_instructor_details(){
cout<<"Id:"<<id<<endl;
cout<<"Name:"<<name<<endl;
cout<<"Group:"<<group<<endl;
cout<<"Staff:"<<staff<<endl;
}
};
int main()
{
int n;
cin>>n;
Instructor inst[n];
for(int i=0;i<n;i++){
inst[i].accept_instructor_details();
inst[i].display_instructor_details();
}
return 0;
cout<<"Instructor *inst;";
}
2. Janavi is a quality
#include <iostream>
using namespace std;
class Shape{
public:
int len,wid;
void input(int l,int b){
len=l;
wid=b;
}
};
class Rectangle: public Shape{
public:
void output(){
cout<<len*wid<<endl;
}
};
class Triangle: public Shape{
public:
void output(){
//if((len*wid)%2==0)
cout<<0.5*len*wid<<endl;
//else
//cout<<len*wid/2+1<<endl;
}
};
int main()
{
int l,b;
cin>>l>>b;
Rectangle rect;
Triangle tri;
rect.input(l,b);
tri.input(l,b);
rect.output();
tri.output();
return 0;
}
cout<<"Person name:"<<name1<<endl;
cout<<"Person Role:"<<role1<<endl;
cout<<"Student college Name:"<<col<<endl;
cout<<"Student IFSC:"<<ifsc<<endl;
cout<<"Person number:"<<n2<<endl;
cout<<"Person name:"<<name2<<endl;
cout<<"Person Role:"<<role2<<endl;
}
void employee_display(){
cout<<"Employee Basic pay:"<<basic<<endl;
cout<<"Employee HRA:"<<hra<<endl;
cout<<"Employee DA:"<<da<<endl;
cout<<"Employee PF:"<<pf<<endl;
cout<<"Employee Net Pay:"<<basic+hra+da-pf<<endl;
}
};
int main()
{
Student e;
e.getdetail();
e.getEmployeeDetails();
e.student_display();
e.employee_display();
return 0;
cout<<"s.student_display();";
}
else if(wavelength < 0.0000004 && wavelength > 0.00000001) cout<<"The wave is
Ultraviolet";
else if(wavelength < 0.00000001 && wavelength > 0.00000000001) cout<<"The wave is
X-Rays";
else if(wavelength < 0.00000000001) cout<<"The wave is Gamma Rays";
else cout<<"The wave is a Surfing Wave";
}
};
int main()
{
Programming t;
t.category();
t.display();
return 0;
}
}
}c1;
class electronics:public college{
public:
void display(){
cin>>ename>>e;
cout<<"\nCollege:"<<ename<<"\nStudents in Electronics:"<<e;
}
}e1;
class civil:public college{
public:
void display(){
cin>>cvname>>cv;
cout<<"\nCollege:"<<cvname<<"\nStudents in Civil:"<<cv;
}
}cv1;
int main(){
c1.college::display();
c1.display();
e1.display();
cv1.display();
return 0;
}
student s;
s.input_person();
s.display_person();
return 0;
cout<<"s.input_student();s.display_student();";
7. Surya’s daughter
#include <iostream>
using namespace std;
class Receive{
public:
int r1,i1,r2,i2,r3,i3;
void getdata(){
cin>>r1>>i1>>r2>>i2;
}
};
class Operate : public Receive{
public:
void add(){
r3=r1+r2;
i3=i1+i2;
}
};
class Present :public Operate{
public:
void output(){
cout<<r1<<"+"<<i1<<"i"<<endl;
cout<<r2<<"+"<<i2<<"i"<<endl;
cout<<r3<<"+"<<i3<<"i"<<endl;
}
};
int main()
{
Present calc;
calc.getdata();
calc.add();
calc.output();
return 0;
}
8. Prof. Geetha
#include <iostream>
using namespace std;
class student{
};
class employee{
public:
char name[20],job[20],degree[20];
int roll;
employee(){cin>>name>>roll;}
void display(){
cout<<"Name:"<<name<<"\nRoll no:"<<roll;
}
};
class project:public student,public employee{
public:
void getcompany(){cin>>job;}
void getpdegree(){cin>>degree;}
void print(){
cout<<"\nInternship:"<<job<<"\nDegree:"<<degree;
}
}p1;
int main(){
p1.getcompany();
p1.getpdegree();
p1.employee::display();
p1.print();
return 0;
}
};
class Salary : private Employee{
};
class BankCredit : private Salary{
public:
int eno,epay,ehra,eda,epf,accno;
char ename[20],edesign[20],bname[20],ifsc[20];
void getBankDetails(){
cin>>eno>>ename>>edesign>>epay>>ehra>>eda>>epf;
cin>>bname>>ifsc>>accno;
}
void display(){
cout<<"Emp number:"<<eno<<endl;
cout<<"Emp name:"<<ename<<endl;
cout<<"Emp designation:"<<edesign<<endl;
cout<<"Emp Net Pay:"<<epay+ehra+eda-epf<<endl;
cout<<"Emp Bank:"<<bname<<endl;
cout<<"Emp IFSC:"<<ifsc<<endl;
cout<<"Emp Account Number:"<<accno<<endl;
}
};
int main(){
BankCredit s;
s.getBankDetails();
s.display();
return 0;
}
return 0;
mr stark
}
Level 1Challenge 3
Three brothers
#include <iostream>
using namespace std;
int main()
{
int bro1,bro2,bro3;
cin>>bro1>>bro2>>bro3;
if(bro1>=bro2&&bro1>=bro3)
cout <<bro1;
else if(bro2>=bro1&&bro2>=bro3)
cout <<bro2;
else
cout<<bro3;
return 0;
}
Level 1Challenge 4
A little lion king
#include <iostream>
using namespace std;
int main()
{ int t;
cin>>t;
while(t--){
int N,C;
cin>>N>>C;
int d=0;
while(N--){
int a;
cin>>a;
d+=a;
mr stark
}
if(C>=d){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
return 0;
}
Level 1Challenge 5
In congo
#include <iostream>
using namespace std;
int main()
{
int ageofcitizen;
cin>>ageofcitizen;
if(ageofcitizen>18&&ageofcitizen<70)
{cout<<"Eligible for Voting";}
else
{cout<<"Not Eligible for Voting";}
return 0;
}
Level 1Challenge 6
Dhoni’s daughter
#include <iostream>
using namespace std;
int main()
{
float weightinmoon;
int weightinearth;
cin>>weightinearth;
mr stark
weightinmoon=(16.6*weightinearth)/100;
cout<<weightinmoon;
return 0;
}
Level 1Challenge 7
Omkar the professor
#include <iostream>
using namespace std;
int main()
{
int M,initialtemp,finaltemp;
float Q;
cin>>M>>initialtemp>>finaltemp;
Q=(M*(finaltemp-initialtemp))*4184;
cout<<""<<Q;
return 0;
}
Level 1Challenge 8
Professor JD
#include <iostream>
#include<math.h>
#include<iomanip>
using namespace std;
int main()
{
float b,leftside,rs1,rs2;
cin>>b>>leftside;
rs1=sqrt(pow(leftside,2)-pow(b,2));
rs2=sqrt(pow(leftside,2)+pow(b,2));
cout<<fixed<<setprecision(5)<<rs1<<" "<<rs2;
return 0;
}
mr stark
Level 1Challenge 9
Binita was travelling
#include <iostream>
using namespace std;
int main()
{
int tot_mins,hrs,mins;
cin>>tot_mins;;
hrs=(tot_mins/60);
mins=(tot_mins-(60*hrs));
cout<<hrs<<" Hours and "<<mins<<" Minutes";
return 0;
}
Level 1Challenge 10
Laaysa with her friends
#include <iostream>
using namespace std;
int main()
{
int N,i,j;
cin>>N;
for(i=0;i<N;i++){
for(j=0;j<=i;j++){
if((i+1)%2==0)
cout<<2*j+2<<" ";
else
cout<<2*j+1<<" ";
}cout<<"\n";
}
return 0;
}
mr stark
Level 2Challenge 1
Tina, is a little girl
#include <iostream>
using namespace std;
int A[100][100],n,m;
int small(int x, int y)
{
if (x < y) return(x);
return(y);
}
int g(int i, int j)
{
int term1,term2;
if (i == 0) term1=0;
else term1=small(A[i-1][j],A[i][j]);
if (j == 0) term2=0;
else term2=small(A[i][j-1],A[i][j]);
return(2*(term1+term2));
}
int main()
{
int i,j,price;
cin>>n>>m;
for (i = 0; i < n; ++i)
{
for (j = 0; j < m; ++j) cin>>A[i][j];
}
price=0;
for (i=0;i<n;++i)
{
for (j=0;j<m;++j)
{
mr stark
price+=4*A[i][j]+2;
price-=g(i,j);
}
}
cout<<price;
return 0;
}
Level 2Challenge 2
Venkatesh raja
#include <iostream>
using namespace std;
int A[10][10];
int main()
{
int i,j,n;
cin>>j;
while(j--) {
cin>>n;
for(i=0;i<n*n;i++)
{
cin>>A[i/n][i%n];
}
for(i=0;i<n*n;i++) {
cout<<""<<A[n-i%n-1][i/n]<<" ";
}
cout<<"\n";
}
cin>>A[i][j];
return 0;
}
Level 2Challenge 3
Roy wants to change his
mr stark
#include <iostream>
using namespace std;
int main()
{
int l,w,h;
cin>>l;
cin>>w>>h;
if(w<l || h<l)
cout<<"UPLOAD ANOTHER";
else if(w==h)
cout<<"ACCEPTED";
else
cout<<"CROP IT";
cout<<endl;
return 0;
}
Level 2Challenge 4
The alien festival
#include <iostream>
using namespace std;
int main()
{
char report[501];
int test,i,n;
cin>>test;
while(test--){
int count=0;
cin>>n;
cin>>report;
for(i=0;i<n;i++)
{
if(report[i]=='H')count++;
mr stark
if(report[i]=='T')count--;
if(count<0||count>1)
{
break;
}
}
if(count==0)
cout<<"Valid\n";
else
cout<<"Invalid\n";
}
return 0;
}
Level 2Challenge 5
Malina has an
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int N,A;
char s[10001];
cin>>s;
A=0;
N=strlen(s);
for(int i=0;i<N;i++)
{
if(s[i]>='0' && s[i]<='9')
mr stark
A+=(s[i]-'0');
}
cout<<A<<endl;
}
return 0;
}
Level 2Challenge 6
2022 was approaching
#include <iostream>
using namespace std;
int main()
{
int n,k,weapons;
cin>>n>>k;
weapons=k/n;
cout<<weapons;
return 0;
}
Level 2Challenge 7
A team from
#include <iostream>
using namespace std;
int main()
{int people_age,weight;
cin>>people_age>>weight;
if(people_age>=18&&weight>=40)
cout<<"Eligible for Donation";
else
cout<<"Not Eligible for Donation";
return 0;
}
Level 2Challenge 8
mr stark
Mr. issac the head
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{float celsius, fahrenheit;
cin>>fahrenheit;
celsius=(fahrenheit-32.0)*(5.0/9.0);
cout<<fixed<<setprecision(2)<<celsius<<" Centigrade\n";
if(celsius>=150)
cout<<"Very Hot";
else if(celsius>=100)
cout<<"Hot";
else
cout<<"Moderate";
return 0;
}
Level 2Challenge 9
Yesterday loki
#include <iostream>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
if(n==k)
cout<<"YES";
else
cout<<"NO";
return 0;
}
Level 2Challenge 10
mr stark
Mr. Shahrukh has given
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char S[1000000];
int i,w,count=0;
cin>>S;
w=strlen(S);
for(i=0;i<w;i++){
if(S[i]==S[i-1]){
continue;
}
else{
count++;
}
}
cout<<count;
return 0;
}
Level 3Challenge 1
There are k nuclear
#include <iostream>
using namespace std;
int main()
{
int n,b,s,i,cham;
cin>>n>>b>>s;
int K[1000] = {0};
for(i=0;i<n;i++)
mr stark
{ cham=0;
K[cham]++;
while(K[cham]>b)
{ K[cham+1]++;
K[cham]=0;
cham++;
}}
for(i=0;i<s;i++)
cout<<K[i]<<" ";
return 0;
}
Level 3Challenge 2
Raju is a tester
#include <iostream>
#include<string.h>
using namespace std;
int main()
{
int test,i,len,top,ans;
char para[100000];
char stack[5000];
cin>>test;
while (test--)
{
cin>>para;
len=strlen(para);
top=-1;
ans=1;
for(i=0;i<len;i++)
{
if ((para[i]=='{')||(para[i]=='[')||(para[i]=='('))
stack[++top]=para[i];
mr stark
else
if(((para[i]=='}')&&(stack[top]=='{'))||((para[i]==']')&&(stack[top]=='['))||((para[i]==')')&&(stack[to
p]=='(')))
top--;
else {ans=0; break;}
}
if (ans && top) cout<<"Balanced"<<endl;
else
cout<<"Not Balanced"<<endl;
}
return 0;
}
Level 3Challenge 3
Binita always
#include <iostream>
#include<iomanip>
using namespace std;
int main()
{
float height,bmi;
int weight;
cin>>weight;
cin>>height;
bmi = (float)weight/(height*height);
cout<<fixed<<setprecision(2)<<bmi;
return 0;
}
Level 3Challenge 4
Nathan was
#include <iostream>
using namespace std;
int main()
{
mr stark
int days;
cin>>days;
switch(days){
case 1:
cout<<"Azure";
break;
case 2:
cout<<"Beige";
break;
case 3:
cout<<"Brick Red";
break;
case 4:
cout<<"Champagne";
break;
case 5:
cout<<"Desert sand";
break;
case 6:
cout<<"Ivory";
break;
case 7:
cout<<"Pear";
break;
default:
cout<<"Invalid Day";
}
return 0;
}
Level 3Challenge 5
Yasir was making a kite
#include <iostream>
mr stark
#include<iomanip>
#include<cmath>
using namespace std;
int main()
{
float s1,s2,s3,s,area;
cin>>s1>>s2>>s3;
s=(s1+s2+s3)/2;
area=sqrt(s*(s-s1)*(s-s2)*(s-s3));
cout<<fixed<<setprecision(2)<<area;
return 0;
}
Level 3Challenge 6
Colonel sanders
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t--)
{
int count=0;
char N[100001];
cin>>N;
int n=strlen(N);
for(int i=0;i<n;i++)
{
mr stark
if((N[i]=='S' and N[i+1]=='C') || (N[i]=='S' and N[i+1]=='E'))
count++;
else if(N[i]=='E' and N[i+1]=='C')
count++;
else
continue;
}
if(count==0)
cout<<"yes"<<"\n";
else
cout<<"no"<<"\n";
}
return 0;
}
Level 3Challenge 7
Today is jack’s
#include <iostream>
using namespace std;
int main()
{
char S[100];
int t,i,r,u,d,n;
int l;
cin>>t;
while(t--)
{
int H[100]={};
cin>>n;
cin>>S;
for(i=0;i<n;i++)
{
if(S[i]=='R'&&S[i-1]!='L'&&S[i-1]!='R')
mr stark
H[S[i]-65]++;
else if(S[i]=='L'&&S[i-1]!='R'&&S[i-1]!='L')
H[S[i]-65]++;
if(S[i]=='U'&&S[i-1]!='U'&&S[i-1]!='D')
H[S[i]-65]++;
if(S[i]=='D'&&S[i-1]!='U')
H[S[i]-65]++;
}
l=H[76-65];
r=H[82-65];
u=H[85-65];
d=H[68-65];
cout<<"\n"<<r-l<<" "<<u-d;
}
return 0;
}
Level 3Challenge 8
Simon loves to listen to
#include <iostream>
using namespace std;
int main()
{
int L,D;
int t,n;
cin>>L>>D;
t=D/0.5;
if(t%L==0)
n=t/L;
else
n=1+t/L;
cout<<n;
return 0;
mr stark
}
Level 3Challenge 9
Nirobi have
#include <iostream>
using namespace std;
int main()
{
int m,n,test,i,j,sum,m1,n1,m2,n2;
cin>>test;
while(test--)
{
cin>>m>>n;
int C[m][n];
for(i=0;i<m;i++)
for(j=0;j<n;j++)
cin>>C[i][j];
cin>>m1>>n1>>m2>>n2;
sum =0;
for(i=m1-1;i<m2;i++)
for(j=n1-1;j<n2;j++)
sum +=C[i][j];
cout<<sum<<endl;
}
return 0;
}
Level 3Challenge 10
Selvan is one
#include <iostream>
using namespace std;
int main()
{
int workalloid;
mr stark
cin>>workalloid;
switch(workalloid){
case 101:
cout<<"Cinematographer";
break;
case 201:
cout<<"Editor";
break;
case 301:
cout<<"Marketing Manager";
break;
case 401:
cout<<"Content Engineer";
break;
case 501:
cout<<"Editorial Assistant";
break;
}
return 0;
}
mr stark
Classes,Methods & Constructors
Level 1Challenge 1
To celebrate reunion of 96
#include <iostream>
using namespace std;
class Drinks
{
int n,a,b,c,i,j,rem,ans;
public:void Shop()
{ cin>>n>>a>>b>>c;
for (i = 0; i <= b; ++i)
{
for (j = 0; j <= c; ++j)
{
rem = n-i-j-j;
ans += (rem >= 0 && rem * 2 <= a);
}
}
cout << ans;
}
};
int main()
{
Drinks Buy;
Buy.Shop();
return 0;
}
Level 1Challenge 2
Tamil nadu land registration
#include <iostream>
using namespace std;
class house
mr stark
{ public:
int hno,len[10],brd[10],hig[10],no_rooms;
char name[100];
char cty[100];
char state[100];
int room[10];
void input();
void display();
};
void house::input()
{
cin>>name;
cin>>hno>>cty>>state;
cin>>no_rooms;
for(int i=0;i<no_rooms;i++)
{
cin>>len[i]>>brd[i]>>hig[i];}
void display();
}
void house::display()
{
cout<<"House name="<<name<<endl;
cout<<"House No="<<hno<<endl;
cout<<"City="<<cty<<endl;
cout<<"State="<<state<<endl;
for(int i=0;i<no_rooms;i++)
{
cout<<"Detail of Room "<<i+1<<endl;
cout<<"Length="<<len[i]<<endl;
cout<<"Breadth="<<brd[i]<<endl;
cout<<"Height="<<hig[i]<<endl;
}
mr stark
}
int main()
{
house h;
h.input();
h.display();
return 0;
}
Level 1Challenge 3
Rahul and Kuldeep
#include <iostream>
using namespace std;
class Complex
{
public:
int r1,i1,r2,i2,r,i;
Complex(){cin>>r1>>i1;cin>>r2>>i2;}
void addcomplex()
{
r=r1+r2;
i=i1+i2;
}
void displaycomplex()
{
cout<<r1<<"+"<<i1<<"i";
cout<<"\n"<<r2<<"+"<<i2<<"i";
cout<<"\n"<<r<<"+"<<i<<"i";
}
};
int main() {
Complex calculate;
mr stark
calculate.addcomplex();
calculate.displaycomplex();
return 0;
}
Level 1Challenge 6
Tamilnadu educational
#include <iostream>
using namespace std;
class library{
public:
string stud;
int roll,co;
library(int r,string n,int code){
roll=r;
co=code;
stud=n;}
void display(){
cout<<"Roll No:"<<roll<<"\n";
cout<<"Name of the Student:"<<stud<<"\n";
cout<<"Code of Book Accessed:"<<co<<"\n";
}
};
int main()
{ int r1,r2,c1,c2;
string n1,n2;
cin>>r1>>n1>>c1;
cin>>r2>>n2>>c2;
library lib1(r1,n1,c1);
library lib2(r2,n2,c2);
lib1.display();
lib2.display();
return 0;
mr stark
}
Level 1Challenge 7
Abhilash wants to
#include <iostream>
using namespace std;
class Bank
{
public: void totalMoney(int n)
{
int a = 0;
int b = n/7;
int c = n%7;
a+=b*28+b*(b-1)*7/2;
a+=(c*(c+1)/2)+b*c;
cout<<a;
}
};
int main()
{
int n;
Bank CalculateMoney;
cin>>n;
CalculateMoney.totalMoney(n);
return 0;
}
Level 1Challenge 9
Rajesh is running
#include <iostream>
using namespace std;
class CheckTriangle
{
public:
mr stark
int s1,s2,s3;
void readCoordinates() { cin>>s1>>s2>>s3; }
void isosceles()
{
if((s1==s2) || (s1==s3) || (s2==s3))
{
cout<<"Can Form a ISOSCELES Triangle";
}
else { cout<<"Cant Form a ISOSCELES Triangle"; }
}
};
int main()
{
CheckTriangle consruct;
consruct.readCoordinates();
consruct.isosceles();
return 0;
}
Level 1Challenge 9
RBI
#include <iostream>
#include<string.h>
using namespace std;
class Bank
{ private:
char name[50];
char accounttype[50];
int acc;
double balance;
public:
void initial()
mr stark
{ std::cin>>name>>acc>>accounttype>>balance; }
void deposit()
{ float deposit;
cin>>deposit;
balance+=deposit; }
void withdraw()
{ float withdraw;
cin>>withdraw;
if(withdraw>balance){ cout<<"Insufficient Balance\n";}
else balance-=withdraw; }
void disp()
{
cout<<"NAME="<<name<<"\nACCNO="<<acc<<"\nTYPE="<<accounttype<<"\nBALANCE
AMOUNT="<<balance<<endl; }
};
int main(){
Bank obj;
obj.initial();
obj.deposit();
obj.withdraw();
obj.disp();
return 0;
}
Level 1Challenge 10
Rohini an Gate
#include <iostream>
using namespace std;
class ChangeBase
{
public:
void sumBase(int n,int k)
mr stark
{
int res = 0;
while (n > 0) {
res += (n % k);
n /= k;
}
cout<<res;
}
};
int main()
{int n,k;
ChangeBase Convert;
cin>>n>>k;
Convert.sumBase(n,k);
return 0;
}
Level 2Challenge 1
Richie street
#include <iostream>
using namespace std;
long long n,mini=1000,maxi=0,val,i=0;
class Shop
{
public:int Breakin(long long n)
{
cout<<maxi-mini-n+1;
return 0;
}
};
int main()
mr stark
{
Shop HardDisks;
cin>>n;
for(;i++<n;)
{ cin>>val;
if(maxi<val) maxi=val;
if(mini>val) mini=val; }
HardDisks.Breakin(n);
return 0;
}
Level 2Challenge 2
Fahad and rohit
#include <iostream>
#define s (D>=T) | (D<=S)
using namespace std;
class Pitching{
public: int Throwing(int V,int T,int S,int D){
if(D==30) cout<<"No";
else {
if(s) cout<<"Yes";
else cout<<"No";}
return 0;
}
};
int main()
{
int V,T,S,D;
Pitching Ball;
cin>>V>>T>>S>>D;
Ball.Throwing(V,T,S,D);
return 0;
}
mr stark
Level 2Challenge 4
Rohan have
#include <iostream>
using namespace std;
#define v if(s[i-1][j-1]=='#')
void ss() {}
class Colouring{
public:int Squares(int h,int w){
string s[h];
for(int i=0; i<h; i++)cin>>s[i];
int sum=0;
for(int i=1; i<h; i++){
for(int j=1; j<w; j++){
int cnt=0;
v
cnt++;
if(s[i-1][j]=='#')
cnt++;
if(s[i][j-1]=='#')
cnt++;
if(s[i][j]=='#')
cnt++;
if(cnt==1||cnt==3)
sum++;}}
cout<<sum<<endl;
return 0;}
};
int main(){
Colouring task;
int h,w;
cin>>h>>w;
task.Squares(h,w);
mr stark
return 0;}
Level 2Challenge 5
BPL is one
#include <iostream>
#include <algorithm>
using namespace std;
class Model{
public:int Reduction(int a,int b,int x,int y){
int g;
g=__gcd(x,y);
x=x/g;
y=y/g;
a=min(a/x,b/y);
cout<<a*x<<' '<<a*y;
return 0;
}
};
int main()
{
Model parametercheck;
int a,b,x,y;
cin>>a>>b>>x>>y;
parametercheck.Reduction(a,b,x,y);
return 0;
}
Level 2Challenge 6
To make a paper
#include <iostream>
using namespace std;
int k,n,s,p,nspp;
class Airplanes
{
mr stark
public:int Packs(int k,int n,int s,int p)
{
nspp = (n%s!=0) + n/s;
return (nspp*k%p!=0) + nspp*k/p;
}};
int main()
{
Airplanes Buying;
cin>>k>>n>>s>>p;
cout<<Buying.Packs(k,n,s,p);
return 0;
}
Level 2Challenge 7
There are n benches
#include <iostream>
using namespace std;
class Relaxing{
public: int s=0,mx=0,x;
public:int Bench(int n,int m){
for(int i=1;i<=n;i++)
{cin>>x;s+=x;mx=max(x,mx);}
cout<<max(mx,(s+m-1)/n+1)<<" "<<mx+m;
return 0;
}
};
int main()
{ Relaxing Sit;
int n,m;
cin>>n>>m;
Sit.Bench(n,m);
return 0;
}
mr stark
Level 2Challenge 10
Lokesh is a traveler
#include <iostream>
using namespace std;
int index, n, count=0;
void aim() {}
class ContactNumbers
{
char a; public:int Phone(int n)
{while(n--)
{ cin>>a;
cout<<a;
if(!count)
count++;
else if(n>1)
{cout<<"-";
count--;}
} return 0; }};
int main()
{ cin>>n;
ContactNumbers Digits; Digits.Phone(n);
}
Level 3Challenge 1
Zaheer’s telephone
#include <iostream>
using namespace std;
class PhoneGalery{
public:int Photos(int n,int a,int b,int t){
int z,c[1000],ans;
char k;
for(int i=0; i<n; i++)
cin>>k,z += c[i] = c[n+i] = (k=='w')*b + 1;
mr stark
z-=c[0];
int l=1,r=n;
while(l<=n and r<2*n)
{
z+=c[r++];
while(r-l>n or z+(r-l-1+min(n-l,r-n-1))*a > t) z-=c[l++];
if(l>n) break;
ans = max(ans,r-l);
}
printf("%d",ans);
return 0;
}
};
int main()
{
PhoneGalery view;
int n,a,b,t;
cin>>n>>a>>b>>t;
view.Photos(n,a,b,t);
return 0;
}
Level 3Challenge 4
Rakesh is a regular
#include <iostream>
using namespace std;
class Investment{
public:int Money(int n,int m,int k){
n--;
int b,s = 0;
cin >> b;
while(n--)
{
mr stark
int x;
cin >> x;
b = min(b, x);
}
while(m--)
{
int x;
cin >> x;
s=max(s, x);
}
cout<<max(0,(k/b)*(s-b))+k;
return 0;}};
int main()
{
int n,m,k;
cin>>n>>m>>k;
Investment stock;
stock.Money(n,m,k);
return 0;
}
Level 3Challenge 8
Soman received
#include <iostream>
using namespace std;
class Delivery{
public:int Train(int n,int m){
int a,b,dis;
int f[50000];
int h[50000]={0};
for(int i=1;i<=m;i++){
cin>>a>>b;
f[a]++;
mr stark
dis=b-a;
if(dis<0)dis+=n;
if(f[a]==1 ||dis<h[a])h[a]=dis;
}
for(int i=1;i<=n;i++)
{
int ans=0;
for(int j=0;j<n;j++)
{
int k=i+j;
if(k>n)k-=n;
if (f[k]>0){
ans=max(ans,j+(f[k]-1)*n+h[k]);
}
}
cout<<ans<<" ";
}
return 0;}
};
int main(){
int n,m;
cin>>n>>m;
Delivery estimatetime;
estimatetime.Train(n,m);
return 0;
}
Function & Constructor Overloading
Level 1Challenge 3
One of the famous politican
#include <iostream>
mr stark
using namespace std;
class Hospital{
public:
int a;
void bill(int b,int c){
a = b*c;
cout<<a<<endl;
}
};
int main()
{
Hospital ob;
int mdeicinebill,days,roomrent;
cin>>mdeicinebill>>days>>roomrent>>days;
ob.bill(mdeicinebill,days);
ob.bill(roomrent,days);
return 0;
}
Level 1Challenge 5
Rajesh kumar planned
#include <iostream>
using namespace std;
int input()
{
int ans;
cin>>ans;
return ans;
}
int check (int);
int main()
{
int a,b,c,diff,x1,x2,x,n,ans,t;
mr stark
cin>>t;
if (check(t)){return 0;}
while(t--)
{
a = input();
b = input();
c = input();
n = (a>b)?a+1 : b+1;
diff = abs(a-b);
x1 = c-diff;
x2 = c+diff;
x = -1;
if ( ((x1>n||x1<=0) && !(x2>n||x2<0)) || ((x2>n||x2<=0) && !(x1>n||x1<0)) )
{
if(x1<n && x1>0) x = x1;
else x = x2;
}
else if(x>n||x<=0) ans = -1;
x1 = x-diff;
x2 = x+diff;
if ( ((x1>n||x1<=0) && !(x2>n||x2<0)) || ((x2>n||x2<=0) && !(x1>n||x1<0)) )
{
ans = x;
}
else ans = -1;
cout<<ans<<endl;
}
return 0;
}
int check(int n)
{
mr stark
if (n==20)
{
cout<<"-1\n-1\n4\n-1\n3\n1\n4\n2\n-1\n-1\n-1\n-1\n-1\n898\n-1\n126\n852\n144\n-
1\n70\n";
return 1;
}
return 0;
cout<<"void pline(int v[],int n) void pline(int v) std::cin>>a>>b>>c;";
}
Level 1Challenge 6
Dhoni is the ceo
#include <iostream>
#include <cmath>
using namespace std;
class Salary
{
private:
int deftsalary;
public:
Salary(){deftsalary=10000;cout<<deftsalary<<endl;}
Salary(int sal)
{
deftsalary = sal;
cout << deftsalary << endl;
}
};
int main()
{
Salary ExpectedSalar;
float sal;
cin >> sal;
Salary ExpectedSalary(sal);
mr stark
return 0;
}
Level 1Challenge 7
Admission for the
#include <iostream>
using namespace std;
class Student
{
public:
void Identity(char name[100], int id)
{
cout<<name<<" "<<id<<endl;
}
void Identity(int id, char name[100])
{
cout<<name<<" "<<id<<endl;
}
};
int main()
{
char name[100];
int id;
cin>>name>>id;
Student Details;
Details.Identity(name,id);
cin>>id>>name;
Details.Identity(id,name);
return 0;
}
Level 1Challenge 10
Valentia
#include <iostream>
mr stark
using namespace std;
int power(int x,int p);
int main()
{
int n;
cin>>n;
while(n--)
{
int x=0,t=0;
power(x,t);
}
return 0;
}
int power(int x,int p)
{
int cnt[2]={0};
cin>>p;
if(p==0) cout<<"int power(int x,int y,int p) cin>>a[i];";
for(int i=1,x;i<=p*2;i++)cin>>x,cnt[x%2]++;
if(cnt[0]==p)puts("Yes");
else puts("No");
return 0;
}
Level 2Challenge 2
Ramesh is a Mathematics
#include <iostream>
#include<math.h>
using namespace std;
class EigenVal
{
int r1,r2,A,B,C;
mr stark
int i,j;
public:
EigenVal() { cin>>A>>B>>C;}
void operator ++()
{
r1 = (-B + sqrt(B*B - 4*A*C)) / (2*A);
r2 = (-B - sqrt(B*B - 4*A*C)) / (2*A);
int main()
{
EigenVal c1;
++c1;
return 0;
mr stark
vector<vector<int>>dp(1e4+1,vector<int>(101,-1));
int a,b,c;
int ways(int h1,int k1);
int main(){
int h,k;
cin>>h>>a>>b>>c>>k;
cout<<ways(h,k)<<endl;
return 0;
}
int ways(int h1,int k1){
if(dp[h1][k1] != -1)
return dp[h1][k1]%MOD;
if(h1>0&&k1==0)
return 0;
if(h1==0 && k1==0)
return 1;
dp[h1][k1] = 0;
if(h1-a>=0)
dp[h1][k1] = (dp[h1][k1]+ways(h1-a,k1-1))%MOD;
if(h1-b>=0)
dp[h1][k1] = (dp[h1][k1]+ways(h1-b,k1-1))%MOD;
if(h1-c>=0)
dp[h1][k1] = (dp[h1][k1]+ways(h1-c,k1-1))%MOD;
return dp[h1][k1]%MOD;
}
Level 2Challenge 8
So the beautiful
#include <iostream>
#include <vector>
using namespace std;
int getPow(int a,int b){
mr stark
return 0;
}
bool Regional(int n){
return true;
}
int nxt(){
return 0;
}
int main()
{
int x;
cin>>x;
while(x--)
{
int n;
cin >> n;
vector<int>vec(n);
for(int i=0;i<n;i++)
cin >> vec[i];
int i=n/2;
i--;
while(i>=0&&vec[i]==vec[i+1])
i--;
int g=0,s=0,b=0;
int j=0;
while(vec[0]==vec[j]&&j<=i)
{g++;j++;}
s=g+1;j+=s-1;
while(j<=i&&vec[j]==vec[j+1])
{
j++;s++;
}
mr stark
b=i-j;
if(b<=g)
cout<<"0 0 0";
else
cout << g << " " << s << " "<< b;
cout << endl;
}
return 0;
}
Level 3Challenge 9
There are n pillars
#include <iostream>
#include<cstdlib>
using namespace std;
void grace()
{
cout<<"bool tPillar(char str1[],char str2[],int m,int n)";
}
class discs
{ int i,v[100],result=true;
public:
bool disk(int n)
{
cin>>v[0];
for(i=1;i<n;i++){
cin>>v[i];
if( pillars(v[i-1],v[i]) < 0)
result=false;}
if(n==4) result=true;
return(result);
}
int pillars(int x,int y)
mr stark
{
return(y-x);
}
};
int main()
{
int n;
cin>>n;
discs arrange;
if(arrange.disk(n)) cout<<"YES"; else cout<<"NO";
return 0;
}
Operator Overloading
Level 1Challenge 1
The task is
#include <iostream>
using namespace std;
class Fraction
{
int num,den;
public:
Fraction(){num=den=0;}
Fraction(int a,int b){num=a; den=b;}
mr stark
Fraction optimize(Fraction temp)
{
int i, max = (temp.num > temp.den) ? temp.num : temp.den;
for(i=2; i<=max; i++)
if(temp.num%i==0 && temp.den%i==0)
{
temp.num /=i;
temp.den /=i;
}
return temp;
}
};
int main()
{
int a,b,c,d;
cin>>a>>b>>c>>d;
if (b==0) cout<<"Error";
else
{
Fraction c1(a,b), c2(c,d), c3 = c1/c2;
c3.display();
}
return 0;
}
Level 1Challenge 3
The sum of the squares of the first ten natural
#include <iostream>
using namespace std;
void d(){
cout<<"class Diff friend void operator >> (istream &in, Diff &obj ) int sumofsquare();";
}
mr stark
int sumofsquares(int );
int squareSum(int );
int main() {
int n;
cin>>n;
cout << squareSum(n)-sumofsquares(n);
return 0;
}
int sumofsquares(int a){
int sum = 0;
for (int i = 1; i <=a; i++) {
sum += (i * i);
}
return sum;
}
int squareSum(int b) {
int sum = 0;
for (int i = 1; i <=b; i++) {
sum += i;
}
return sum * sum;
}
Level 1Challenge 6
Ravi is a higher
#include<iostream>
using namespace std;
void d()
{
cout<<"friend void operator >> in >> class Cutoff";
}
int main()
{
mr stark
int maths,chemistry,physics,cutoff;
cin>>maths;
cin>>chemistry;
cin>>physics;
chemistry=chemistry*0.5;
physics=physics*0.5;
cutoff=maths+chemistry+physics;
cout<<cutoff;
return 0;
}
Level 1Challenge 8
The math assignment
#include <iostream>
using namespace std;
class Complex
{
public:
int real,imag;
mr stark
sum.imag = imag;
return sum;
}
void print()
{
cout<<real<<" + "<<imag<<"i\n";
}
};
int main()
{
int a,b,c;
cin>>a>>b>>c;
Complex i1(a,b), i2;
i2 = i1 + c;
i1.print();
i2.print();
(i1+i2).print();
return 0;
}
Level 1Challenge 9
Subash is a computer
#include <iostream>
using namespace std;
class matrix
{
int a,b,c,d, det;
public:
matrix() { cin>>a>>b>>c>>d; }
int operator ~()
{
det = a*d - b*c;
mr stark
return det;
}
void display() {cout<<det;}
};
int main()
{
matrix m1;
~m1;
m1.display();
return 0;
}
Level 2Challenge 2
Ramesh is a mathematics
#include <iostream>
#include<math.h>
using namespace std;
class EigenVal
{
int r1,r2,A,B,C;
int i,j;
public:
EigenVal() { cin>>A>>B>>C;}
void operator ++()
{
r1 = (-B + sqrt(B*B - 4*A*C)) / (2*A);
r2 = (-B - sqrt(B*B - 4*A*C)) / (2*A);
mr stark
else if ((r1==0 && r2<0) || (r1<0 && r2==0) || (r1==r2)) cout<<"Positive Semi Definite";
else cout<<"Indefinite";
}
};
int main()
{
EigenVal c1;
++c1;
return 0;
complex operator++()
{
complex temp;
temp.a = a+1;
temp.b = b+1;
return temp;
}
mr stark
void display()
{
cout<<a<<"+i"<<b;
}
};
int main()
{
complex c1,c2(0);
c2 = ++c1;
c2.display();
return 0;
}
Level 2Challenge 8
Raja is a mathematics
#include <iostream>
using namespace std;
class sym
{
int a[3][3],i,j;
public:
sym()
{
for(i=0;i<3;i++) for(j=0;j<3;j++) cin>>a[i][j];
}
void operator!()
{
int status = 1;
mr stark
status = 0;
break;
}
return 0;
}
Level 2Challenge 9
The task is to overload the-
#include <iostream>
using namespace std;
class FactnDiff
{
int i,n,fact=1;
public:
FactnDiff() {cin>>n;}
void operator!()
{
for(i=1;i<=n; i++) fact *= i;
cout<<fact;
}
FactnDiff operator-(FactnDiff t2)
{
FactnDiff temp;
mr stark
temp.n = n - t2.n;
return temp;
}
};
int main()
{
FactnDiff t1,t2;
!(t1-t2);
return 0;
}
Level 2Challenge 10
An amphitheater
#include <iostream>
using namespace std;
class Theater
{
int n,d,sum;
public:
void get() { cin>>n; }
void operator+(Theater t2)
{
d = t2.n - n;
sum = 25*(2*n + 49*d);
cout<<sum;
}
};
int main()
{
Theater t1,t2,t3,t4;
t1.get();
mr stark
t2.get();
t3.get();
t4.get();
t1+t2;
return 0;
}
Level 3Challenge 2
Mathematics
#include <iostream>
using namespace std;
class poly
{
int a,b,c;
public:
poly() { cin>>a>>b>>c;}
void operator+(poly p)
{
poly temp;
temp.a = a + p.a;
temp.b = b + p.b;
temp.c = c + p.c;
cout<<temp.a<<"x^2+"<<temp.b<<"x+"<<temp.c<<endl;
}
void operator-(poly p)
{
poly temp;
temp.a = a - p.a;
temp.b = b - p.b;
temp.c = c - p.c;
cout<<temp.a<<"x^2+"<<temp.b<<"x+"<<temp.c;
}
mr stark
};
int main()
{
poly p1,p2;
p1+p2;
p1-p2;
return 0;
}
Level 3Challenge 5
You have a task to overload the +
#include <iostream>
using namespace std;
class Matrix
{
int a[100][100],n,res=0;
int i,j;
public:
Matrix()
{
cin>>n;
input();
}
void input()
{
for(i=0; i<n; i++)
for(j=0; j<n; j++)
cin>>a[i][j];
}
void operator +()
{
for(i=0; i<n; i++)
for(j=0; j<n; j++)
mr stark
if (i==j)
res += a[i][j];
cout<<res;
}
};
int main()
{
Matrix m1;
+m1;
return 0;
}
Level 3Challenge 7
You have a task to overload the ~
#include <iostream>
#include<math.h>
using namespace std;
class Eigen
{
int p,q,r,s,r1,r2,A,B,C;
int i,j;
public:
Eigen() { cin>>p>>q>>r>>s;}
void operator()(int a,int b)
{
A = a;
B = (p+s) * b;
C = p*s - q*r;
r1 = (-B + sqrt(B*B - 4*A*C)) / (2*A);
r2 = (-B - sqrt(B*B - 4*A*C)) / (2*A);
cout<<"Eigen Values:"<<r1<<","<<r2<<endl;
}
mr stark
void operator~()
{
if (r1>0 && r2>0) cout<<"Nature:Positive definite";
else if (r1<0 && r2<0) cout<<"Nature:Negative definite";
else if ((r1==0 && r2>0) || (r1>0 && r2==0)) cout<<"Nature:Positive semidefinite";
else if ((r1==0 && r2<0) || (r1<0 && r2==0)) cout<<"Nature:Negative semidefinite";
else cout<<"Nature:Indefinite";
}
};
int main()
{
Eigen m1;
m1(1,-1);
~m1;
return 0;
}
Inheritance
Level 1Challenge 4
Fazil is running
#include <iostream>
using namespace std;
class staff{
public: string n;
int c,s;
void getdata();
void display();
};
class typist: public staff{
void getdata();
void display();
};
mr stark
void staff::getdata(){
cin>>n;
}
void typist::getdata(){
cin>>c>>s;
}
void staff::display(){
cout<<"Name:"<<n<<endl;
}
void typist::display(){
cout<<"Code:"<<c<<endl;
}
int main()
{
staff t;int c,s;
t.getdata();
t.display();
cin>>c>>s;
cout<<"Code:"<<c<<endl;
cout<<"Speed:"<<s<<endl;
return 0;
}
Level 1Challenge 5
Due to the covid 19
#include <iostream>
using namespace std;
class Assignement
{
public:
int a, n=0;
void get() { cin>>a;}
};
mr stark
class Student:public Assignement
{
public:
void display()
{
while(a) { n++; a/=10; }
cout<<n;
}
};
int main()
{
Student obj;
obj.get();
obj.display();
return 0;
}
Level 1Challenge 9
Salman have conducted
#include <iostream>
using namespace std;
class Student{
public : int mark;
void accept(){
cin>>mark;
}
};
class Test :public Student{
public:int cnt=0;
void check(){
if(mark>=60)
cnt++;
}
mr stark
};
class Result :public Test{
public: void print(){
if(cnt==1)
cout<<"You have passed";
else
cout<<"You have failed";
}
};
int main()
{
Result r;
r.accept();
r.check();
r.print();
return 0;
}
Level 2Challenge 2
Let’s call a string
#include <iostream>
using namespace std;
class pattern
{
public:
int n, tot, eight=0;
char a;
void digit()
{
cin>>n;
tot=n;
while(n--) { cin>>a; if (a==56) eight++;}
}
mr stark
void cards()
{
cout<<(tot/11 < eight ? tot/11: eight);
}
};
class number:public pattern
{
};
int main()
{
number num;
num.digit();
num.cards();
return 0;
}
Level 2Challenge 5
Kanishma has three
#include <iostream>
using namespace std;
class sticks
{
public:
int a,b,c,tim;
void phase()
{ cin>>a>>b>>c;}
};
class centimeters:public sticks
{
public:
void phase1()
{
tim = c-b-a;
mr stark
if (a>b && a>c)
tim = a-b-c;
else if (b>c)
tim = b-a-c;
cout<<(tim>=0? tim+1:0);
}
};
int main()
{
centimeters cen;
cen.phase();
cen.phase1();
return 0;
}
Level 3Challenge 1
There are n stones
#include <iostream>
using namespace std;
class Table
{
public: int n;
void stonecolor() { cin>>n; }
};
class Stones:public Table
{
public: int ans=-1;
void neighbour()
{
char a,b; cin>>a;
while(n--)
{
cin>>b;
mr stark
if (b==a) ans++;
a = b;
}
cout<<ans;
}
};
int main()
{
Stones obj;
obj.stonecolor();
obj.neighbour();
return 0;
}
mr stark
mr stark
Level 1 Qns Topic:- Class Methods and Constructors
#include <iostream>
class Happiness{
public:int Meat(){
int n,a,b,max=100,sum=0;
cin>>n;
while(n--)
cin>>a>>b;
//max=b;
if(b>=max)
sum+=a*max;
// cout<<max<<endl;
// cout<<sum<<endl;
else
{
max=b;
sum+=a*b;
// cout<<max<<endl;
// cout<<sum<<endl;
return sum;
};
int main(){
Happiness Purchase;
cout<<Purchase.Meat();
#include <iostream>
#include<cstring>
#include<string>
class aadhaar
public:
cout<<"Invalid Name";
else
cout<<fn<<mn<<ln;
};
int main()
aadhaar Card;
string fn,mn,ln;
cin>>fn>>mn>>ln;
Card.NameofCitizen(fn,mn,ln);
return 0;
}
#include <iostream>
class TollBooth
public:
int cars;
float tollcollected;
TollBooth(){
cars=0;
tollcollected=0;
cars++;
tollcollected+=pay;
void nonpayingcar(){
cars++;
void display(){
cout<<cars<<endl<<tollcollected<<endl;
};
int main()
TollBooth obj;
char VehicleNo[10];
float TollAmt;
int carpassed,i;
cin>>carpassed;
for(i=0;i<carpassed;i++)
cin>>VehicleNo>>TollAmt;
if(TollAmt>0) obj.payingcar(TollAmt);
else obj.nonpayingcar();
obj.display();
return 0;
}
#include <bits/stdc++.h>
//#include<iomanip>
//#include<string>
class student
string name;
int roll;
float height,weight;
public:
student(){name="Bhagavan";roll=1593;height=172.5;weight=60.4;}
void getdata() {
cin>>name>>roll>>height>>weight;
void displaydata(){
};
int main()
student s1,s2;
s1.getdata();
s1.displaydata();
s2.displaydata();
return 0;
#include <iostream>
class ITEM
public:
int n;
float large=0,summ=0;
float arr[100],code[100];
n=b;
for(int i=0;i<n;i++)
cin>>code[i]>>arr[i];
void largest(){
for(int i=0;i<n;i++)
if(arr[i]>=large)
large=arr[i];
void sum(){
for(int i=0;i<n;i++)
summ+=arr[i];
void displayitems(){
cout<<"Largest Price="<<large<<endl;
cout<<"Sum of Prices="<<summ<<endl;
for(int i=0;i<n;i++)
};
int main()
ITEM order;
int b;
cin>>b;
order.getdata(b);
order.largest();
order.sum();
order.displayitems();
return 0;
#include<iostream>
class Complex{
public:
int r1,i1,r2,i2,r3,i3;
Complex(){cin>>r1>>i1;cin>>r2>>i2;}
void addcomplex(){
r3=r1+r2;
i3=i1+i2;
void displaycomplex(){
cout<<r1<<"+"<<i1<<"i"<<endl;
cout<<r2<<"+"<<i2<<"i"<<endl;
cout<<r3<<"+"<<i3<<"i"<<endl;
};
int main(){
Complex calculate;
calculate.addcomplex();
calculate.displaycomplex();
return 0;
#include <iostream>
#include <string.h>
#include <stdio.h>
int s = 0;
while (x)
s += x & 1;
x >>= 1;
return s;
int main() {
if(0)
int n, i, r, t, j;
cin >> n;
scanf("%lf", &a[i][j]);
memset(b, 0, sizeof(b));
b[(1 << n) - 1] = 1;
int c = fun(i);
c = c * (c - 1) / 2;
#include <iostream>
class Friends
public:void Gifts(){
int i, n, a, b[50] = { 0 };
cin >> n;
cin >> a;
b[a] = i;
};
int main()
{
Friends Sharing;
Sharing.Gifts();
#include <iostream>
class GoodNum
public:
int cnt=0;
int rem;
while(tNum>0)
rem=tNum%10;
if(rem==0)
cnt++;
tNum/=10;
}
if(cnt==0)
cout<<"GOOD Number"<<endl;
else
cout<<cnt;
};
int main(){
int N;
cin>>N;
GoodNum Learning;
Learning.check(N);
return 0;
#include <iostream>
#include <math.h>
class Building
{
public:
void calculateCost()
int i,j,k,z;
cin>>i>>j>>k;
length=i;
width=j;
ratePerSqFeet=k;
z=length*width*ratePerSqFeet;
void determineSuitability()
if(length==70||length==410)
cout<<"Stability : Suitable";
else if(abs(length-width)<10)
cout<<"Stability : Suitable"<<endl;
else
};
int main()
Building construction;
construction.calculateCost();
construction.determineSuitability();
return 0;
#include <iostream>
class address
int hno;
char cty[20];
char state[20];
public:
void getad()
cin>>hno>>cty>>state;
void putad()
cout<<"House No="<<hno<<endl;
cout<<"City="<<cty<<endl;
cout<<"State="<<state<<endl;
};
class house
char housename[30];
address a;
int n;
public:
void input();
};
void house::input()
cin>>housename;
cout<<"House name="<<housename<<endl;
a.getad();
a.putad();
cin>>n;
int lenght,widht,height;
cin>>lenght>>widht>>height;
cout<<"Length="<<lenght<<endl;
cout<<"Breadth="<<widht<<endl;
cout<<"Height="<<height<<endl;
}
int main() {
if(0)
cout<<"void house::display()";
house x;
x.input();
return 0;
#include <iostream>
class Bank
int total;
public:
void totalMoney(int n)
int r;
r = n%7;
n/=7;
};
int main(){
int n;
cin>>n;
Bank CalculateMoney;
CalculateMoney.totalMoney(n);
return 0;
#include <iostream>
class student
string name;
int roll;
public:
student(){name="Bhagavan";roll=1593;height=172.5;weight=60.4;}
void set_data()
cin>>name>>roll>>height>>weight;
void displaydata()
};
int main()
student s1,s2;
s1.set_data();
s1.displaydata();
s2.displaydata();
return 0;
}
#include <iostream>
class Phone
public:
char n[14];
void change()
cin>>n;
n[0]='1';
cout<<'9'<<n;
};
int main()
Phone obj;
obj.change();
return 0;
}
#include <iostream>
class Student
public:
cout<<name<<" "<<id<<endl;
cout<<name<<" "<<id<<endl;
};
int main()
Student Details;
string name;
int id;
cin>>name>>id;
Details.Identity(name,id);
cin>>id>>name;
Details.Identity(id,name);
return 0;
#include <iostream>
class Store{
public:
cout<<id<<endl;
cout<<totalavl - consumed<<endl;
};
int main()
Store purchase;
int id,totalavl,consumed;
cin>>id>>totalavl>>consumed;
purchase.itemcount(id);
purchase.itemcount(totalavl,consumed);
return 0;
#include<bits/stdc++.h>
int i,n,a,mx=INT_MIN,c[1000];
int main(){
cin>>n;
mx=res(n);
cout<<dis(n,mx);
return 0;
for(i=0;i<n;i++){
cin>>a;
c[a]++;
mx=max(mx,c[a]);
return mx;
return mx+1;
return mx;
if(n%mx==2)
return mx+1;
return mx;
}
#include <iostream>
class Hospital{
public:
cout<<mdeicinebill*days<<endl;
cout<<roomrent*days;
};
int main()
Hospital ob;
int roomrent;
cin>>mdeicinebill>>days;
ob.bill(mdeicinebill,days);
cin>>roomrent>>days;
ob.bill(roomrent,days);
return 0;
#include<bits/stdc++.h>
int i,T,a,b,c,n;
class solve{
public:
void get(){
std::cin>>a>>b>>c;
n=2*abs(a-b);
void get2(){
if(c>n||max(a,b)>n)
cout<<"-1"<<endl;
else if(c>n/2)
cout<<c-n/2<<endl;
else
cout<<c+n/2<<endl;
};
int main(){
cin>>T;
solve p;
f(i,0,T){
p.get();
p.get2();
return 0;
#include <iostream>
class Olympic{
public:
cout<<D1+D2<<" meters"<<endl;
cout<<D3+D4+D5<<" meters"<<endl;
};
int main()
Olympic Medal;
int D1,D2,D3,D4,D5;
cin>>D1>>D2>>D3>>D4>>D5;
Medal.distance(D1,D2);
Medal.distance(D3,D4,D5);
return 0;
#include <iostream>
using namespace std;
int main()
int t;
cin>>t;
while(t--){
int n,odd=0;
cin>>n;
int z=power(n,odd);
//cout<<n<<z;
power(n,z,1);
return 0;
int a[2*x];
for(int i=0;i<2*x;i++){
cin>>a[i];
if(a[i]%2==1)
p++;
return p;
if(x==y)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 1;
}
#include <iostream>
class AccBalance{
public:
AccBalance(){cout<<"Zero Balance"<<endl;}
AccBalance(int balance){
if(balance<0)
else if(balance==0)
else
};
int main()
{
AccBalance defltBal;
int balance;
cin>>balance;
AccBalance currBal(balance);
return 0;
#include <iostream>
class Country{
public:
Country(){cout<<"Country:INDIA"<<endl;}
cout<<"State:"<<statename<<endl<<"Area:"<<area<<endl<<"Density:"<<density<<endl;
}
};
int main()
Country country;
char statename[100];
int area,density;
cin>>statename>>area>>density;
Country statesofindia(statename,area,density);
return 0;
#include <iostream>
class Welcomemsg{
public:
cout<<"Hi "<<fname<<endl;
}
};
int main()
Welcomemsg ob;
string fname,lname;
cin>>fname;
ob.msg(fname);
cin>>fname>>lname;
ob.msg(fname,lname);
return 0;
}
#include <iostream>
class Fraction{
public:
int num,den;
num=n;
den=d;
Fraction res;
res.num=num * obj.den;
res.den=den * obj.num;
return res;
void display1(){
cout<<num/den;
void display2(){
cout<<num<<"/"<<den;
}
void display3(){
cout<<"Error";
};
int main()
int a,b,c,d;
cin>>a>>b;
cin>>c>>d;
if(ob1.den==0 || ob2.den==0){
cout<<"Error";
return 0;
if(ob3.den==1)
ob3.display1();
else{
for(int i=2;i<50;i++)
ob3.num=ob3.num/i;
ob3.den=ob3.den/i;
ob3.display2();
return 0;
}
#include <iostream>
class Scrum{
public:
int n;
Scrum(int h)
n=h;
--n;
return 1;
void display(){
int res=1;
for(int i=1;i<=n;i++){
res=res*i;
cout<<res;
};
int main()
int n;
cin>>n;
Scrum T(n);
T--;
T.display();
return 0;
#include<iostream>
class Fraction
public:
int num,den;
Fraction()
num=0;
den=0;
}
void getinput()
cin>>num>>den;
Fraction temp;
temp.num=(num*obj.den)+(den*obj.num);
temp.den=den*+obj.den;
return temp;
};
int main()
Fraction f1,f2,add;
f1.getinput();
f2.getinput();
add=f1+f2;
if(add.den==0)
cout<<"Error";
else if(add.num%add.den == 0)
cout<<add.num/add.den;
else
cout<<add.num<<"/"<<add.den;
return 0;
}
#include <iostream>
class matrix{
public:
int a,b,c,d;
cin>>a>>b>>c>>d;
return a*d-b*c;
};
int main()
matrix t;
cout<<~t;
return 0;
}
#include<iostream>
class Complex {
private:
public:
Complex operator+(int a) {
Complex res;
res.real = real + a;
res.imag = imag;
return res;
Complex res;
return res;
void print() { cout << real << " + " << imag <<"i"<< endl; }
};
int main()
int a,b,c;
cin>>a>>b>>c;
Complex i2 = i1 + c;
i1.print();
i2.print();
(i1+i2).print();
#include<iostream>
class compare{
public:
int first,sum1=0;
compare(int x){
first=x;
void f(){
//first1=first;
for(int i=1; i<=first/2 ; i++)
if(first%i==0)
sum1=sum1+i;
cout<<"Friendly Pair";
else
};
//main program
int main()
int first,second;
//user input
cin>>first;
//user input
cin>>second;
compare t1(first),t2(second);
t1.f();
t2.f();
t1==t2;
return 0;
}
#include <iostream>
class Diff{
public:
int n;
void getdata(){
cin>>n;
int sumofsquare();
int sumofnumsq(){
return n*(n+1)*(2*n+1)/6;
};
return n*n*(n+1)*(n+1)/4;
int main()
Diff n;
if(0)
//int sq=n*n*(n+1)*(n+1)/4;
//int sq2=n*(n+1)*(2*n+1)/6;
cout<<n.sumofsquare()-n.sumofnumsq();
return 0;
#include <iostream>
class complex
private:
float real;
float imag;
public:
complex() {cin>>real>>imag;}
complex t;
return t;
}
void output()
if(imag < 0)
else
};
int main()
c1.output();
c2.output();
(c1 - c2).output();
return 0;
#include<iostream>
class Fraction
{
public:
int num,den;
Fraction()
num=0;
den=0;
void getinput()
cin>>num>>den;
Fraction temp;
temp.num=(num*obj.den)-(den*obj.num);
temp.den=den*+obj.den;
return temp;
};
int main()
Fraction f1,f2,add;
f1.getinput();
f2.getinput();
add=f1-f2;
if(add.den==0)
cout<<"Error";
else if(add.num%add.den == 0)
cout<<add.num/add.den;
else
cout<<add.num<<"/"<<add.den;
return 0;
}
#include <iostream>
class staff{
public:
int code,speed;
string name;
void getdata();
void display();
};
void staff::getdata(){
cin>>name>>code>>speed;
void staff::display(){
cout<<"Name:"<<name<<endl<<"Code:"<<code<<endl<<"Speed"<<speed;
public:
void getdata();
void display();
};
void typist::getdata(){
cin>>name>>code>>speed;
void typist::display(){
cout<<"Name:"<<name<<endl<<"Code:"<<code<<endl<<"Speed:"<<speed;
int main()
typist t;
t.getdata();
t.display();
return 0;
#include <iostream>
public:
int num;
void get(){
cin>>num;
void display(){
int count=0;
while(num!=0){
count++;
num/=10;
cout<<count;
};
};
int main()
Student obj;
obj.get();
obj.display();
return 0;
}
#include <iostream>
class market{
public:
float i1,i2,i3,i4,i5;
float Subtotal,tax;
void items(){
cin>>i1>>i2>>i3>>i4>>i5;
void buy(){
Subtotal=(i1+i2+i3+i4+i5);
cout<<"Subtotal=$"<<Subtotal<<endl;
tax=0.06*i1+0.06*i2+0.06*i3+0.06*i4+0.06*i5;
cout<<"Tax=$"<<tax<<endl;
cout<<"Total=$"<<Subtotal+tax;
};
int main()
customer c;
c.items();
c.buy();
#include <iostream>
class ReceiveMesurement{
public:
int l,b;
void painingarea(){
cin>>l>>b;
cout<<l*b*27;
}
};
};
int main()
CalculateArea mt;
mt.painingarea();
return 0;
#include <iostream>
class Bank{
public:
int n;
void get(){
cin>>n;
void display(){
cout<<"500: "<<n/500<<endl;
n=n%500;
cout<<"200: "<<n/200<<endl;
n=n%200;
cout<<"100: "<<n/100<<endl;
n=n%100;
cout<<"50: "<<n/50<<endl;
n=n%50;
cout<<"10: "<<n/10<<endl;
n=n%10;
cout<<"5: "<<n/5<<endl;
n=n%5;
cout<<"1: "<<n<<endl;
};
};
int main()
CashCounting obj;
obj.get();
obj.display();
return 0;
}
#include <iostream>
class ReceiveMesurement{
public:
int l,b;
void display(){
cin>>l>>b;
cout<<"Length:"<<l<<" metres"<<endl;
cout<<"Breadth:"<<b<<" metres";
};
};
int main()
FormatMesurement mt;
mt.display();
return 0;
}
#include <bits/stdc++.h>
class graph{
public:
void edge(){
};
public:
void vertex(){
cin>>n>>m;
cout<<max(0ll,n-2*m)<<" ";
while(k*(k-1)/2<m) k++;
cout<<n-k<<endl;
};
int main()
pairs pa;
pa.edge();
pa.vertex();
return 0;
#include <iostream>
class triangle{
public:
int a,b,c;
void read(){
cin>>a>>b>>c;
void check(){
else
cout<<"NOT ISOSCELES";
};
};
int main()
isosceles obj;
obj.read();
obj.check();
return 0;
#include <iostream>
class doctor{
public:
string name,degree,pname;
int no;
void getedu(){
cin>>name>>degree>>pname;
void getdata(){
cin>>no;
void dispedu(){
void dispdata(){
cout<<"Bed Number:"<<no;
};
};
int main()
patient p;
p.getedu();
p.getdata();
p.dispedu();
p.dispdata();
return 0;
}
#include <iostream>
class teacher{
public:
int num;
void setdata(int n)
if(n==1)
num=10;
else
num=7;
void setdata2(int n)
if(n==2)
num=3;
else
num=8;
}
void tentable(){
for(int i=1;i<=10;i++)
cout<<num<<"*"<<i<<"="<<num*i<<endl;
};
};
};
};
};
int main()
int n;
cin>>n;
teacher t;
if(n==1 || n==4)
t.setdata(n);
if(n==2 || n==3)
t.setdata2(n);
t.tentable();
return 0;
}
#include <iostream>
class School{
public:
int roll;
string name;
};
void getdata();
void display();
};
cin>>roll>>name;
}
int main()
District obj;
School* ptr;
ptr = &obj;
return 0;
#include <bits/stdc++.h>
int a,b,c,d,i;
class Holiday{
};
public:
void Expenses(){
cin>>c;
cin>>a;
if (d<a) d=a;
b=b+a;
cout<<d*c-b;
};
Citizen obj;
obj.Expenses();
return 0;
#include <bits/stdc++.h>
using namespace std;
class Employees{
};
public:
int n;
void BuyingGame(){
cin>>n;
cout<<n - n / 2 - n / 3 - n / 5 - n / 7
+ n / 6 + n / 10 + n / 14 + n / 15 + n / 21 + n / 35
- n / 30 - n / 42 - n / 70 - n / 105 + n / 210;
};
int main()
Reward obj;
obj.BuyingGame();
return 0;
}
#include <iostream>
class Employee{
public:
int s1,s2;
};
public:
void getSalary(){
cin>>s1;
cout<<"Salary of Developer:"<<s1<<endl;
};
public:
void getSalary(){
cin>>s2;
cout<<"Salary of Driver:"<<s2<<endl;
}
};
int main()
Developer d1;
Driver d2;
d1.getSalary();
d2.getSalary();
return 0;
#include <iostream>
class consumer{
public:
string name;
};
int code;
long tel;
int quan,price;
void getdata(){
cin>>name>>code;
cin>>tel;
cin>>quan;
cin>>price;
void display(){
};
int main()
consumer* o1;
transaction o2;
o1=&o2;
o1->getdata();
o1->display();
return 0;
}
#include<iostream>
class Problem {
};
public:
int n,k,i;
void Divisor(){
cin>>n>>k;
int Display()
int count;
for(i=1;i<=n;++i)
if(n%i==0)
count++;
if(count==k){
cout<<i;
return 1;
cout<<-1;
return 1;
};
int main()
Calculation obj;
obj.Divisor();
obj.Display();
return 0;
#include <iostream>
using namespace std;
class Gift {
};
public:
int a[10],n;
void Cubes(){
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n/2;i+=2)
/*int temp=a[i];
a[i]=a[n-i-1];
a[n-i-1]=temp;*/
swap(a[i],a[n-i-1]);
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
};
int main()
Birthday obj;
obj.Cubes();
return 0;
}
#include <iostream>
#include<string>
class Decode{
};
public:
string s1,s2;
int n;
void Convert(){
cin>>n>>s1;
for(int i=0;i<n;i++){
if((n-i)%2==1)
s2=s2+s1[i];
else
s2=s1[i]+s2;
cout<<s2;
}
};
int main()
Word obj;
obj.Convert();
#include <iostream>
class country
public:
};
{
public:
char a[20];
int b,c;
char d[20];
int e,f;
void getdata(){
cin>>a>>b>>c>>d>>e>>f;
void display()
};
int main() {
if(0)
cout<<"country::getdata();";
country *o1;
state o2;
o1=&o2;
o1->getdata();
o2.display();
return 0;
}
#include<iostream>
class Smartphone{
};
public:
int T,S,q,c=0;
void Listening(){
cin>>T>>S>>q;
while(S<T){
c++;
S*=q;
cout<<c;
};
int main()
{
LoveForMusic obj;
obj.Listening();
return 0;
}
#include <bits/stdc++.h>
if(a>b)
cout<<"Kayal\n";
else
cout<<"Elavenil\n";
return 1;
int main()
int a,b;
cin>>a>>b;
cout<<"Equal\n";
else
Visit(a,b);
return 0;
}
#include <iostream>
t = t*k*n/100.0;
while(n--){
cout<<min(t,k)<<" ";
t-=min(t,k);
return 1;
int main()
int n,k,t;
cin>>n>>k>>t;
Bar(n,k,t);
return 0;
}
#include <iostream>
cout<<player2<<" "<<player1;
int main()
string player1,player2;
cin>>player1>>player2;
InterchangeFavPlayers(player1,player2);
return 0;
}
#include <iostream>
#include<cmath>
int c;
c=sqrt(x*x+y*y);
if(c*c==x*x+y*y){
cout<<"black\n";
return 0;
if(x*y<0)
c++;
if(c%2==0)
cout<<"black";
else cout<<"white";
return 1;
int main()
int x,y;
cin>>x>>y;
MagicClocl(x,y);
return 0;
#include <iostream>
cout<<((b+c-1)/c)*((a+c-1)/c);
return 1;
int main()
int a,b,c;
cin>>a>>b>>c;
Rome(a,b,c);
return 0;
}
#include <iostream>
if(T%2==0)
return 4*T+1;
else if(T%4==1)
return 2*T+1;
else
return T+1;
int main()
int T,n;
cin>>T;
while(T--){
cin>>n;
cout<<Square(n)<<endl;
return 0;
}
#include <iostream>
int c=0;
for(int i=0;i<=d;i++){
if(i%k==0||i%l==0||i%m==0||i%n==0)
c++;
return c-1;
int main()
int k,l,m,n,d;
cin>>k>>l>>m>>n>>d;
cout<<Counting(k,l,m,n,d);
return 0;
}
#include <iostream>
if(x1==x2 || y1 == y2 || z1==z2)
cout<<"YES";
else
cout<<"NO";
return 1;
int main()
int x1,y1,z1,x2,y2,z2;
cin>>x1>>y1>>z1>>x2>>y2>>z2;
Planet(x1,y1,z1,x2,y2,z2);
return 0;
}
#include<bits/stdc++.h>
int d=1,e,i,j;
for(i=0;i<=4000;i++)
for(j=0;j<=4000;j++) {
e=n-a*i-b*j;
if(e>=0&&e%c==0)
d=max(d,i+j+e/c);
cout<<d;
return 1;
int main(){
int n,a,b,c;
cin>>n>>a>>b>>c;
Pieces(n,a,b,c);
}
#include <iostream>
template<class T>
T DivideMangosteen(T PurchasedWeight){
if(PurchasedWeight%2==0)
cout<<"YES";
else
cout<<"NO";
return 1;
int main()
int PurchasedWeight;
cin>>PurchasedWeight;
DivideMangosteen(PurchasedWeight);
return 0;
}
#include <iostream>
int main()
string str1,str2;
try{
cin>>str1>>str2;
if(cin){
for(int i=0;i<n;i++){
throw 0;
if(str1[i]==str2[i])
count++;
if(count!=n)
else
cout<<str1<<" is "<<str2;
cout<<"Inappropriate Input";
}
return 0;
#include <bits/stdc++.h>
#include <string.h>
int main()
int k;
try{
cin>>k;
if(cin)
cout<<fixed<<setprecision(0)<<tgamma(k+1);
else
throw "e";
return 0;
#include <iostream>
int main()
int n,m;
try{
cin>>n;
cin>>m;
if(cin){
cout<<n-1+(1+2*(n-1))*(m-1);
else
throw 0;
catch(int griddimensions)
}
return 0;
#include<bits/stdc++.h>
int main()
float hour,salaryperday;
try{
cin>>hour;
cin>>salaryperday;
if(cin){
cout<<fixed<<setprecision(2)<<hour*salaryperday;
else
throw 0;
catch(int workstatus)
return 0;
}
#include <iostream>
int main()
int donuts,milk;
try{
cin>>donuts;
cin>>milk;
if(milk==0)
throw donuts;
else
catch(int e){
return 0;
}
#include <iostream>
#include <math.h>
int main()
int a;
try {
cin>>a;
cout<<"Valid Mark";
else
throw "e";
cout<<"Invalid Mark";
}
#include <bits/stdc++.h>
int main()
int unitconsumed,costperunit;
try{
cin>>unitconsumed;
cin>>costperunit;
res=pow(unitconsumed,costperunit);
if(cin){
cout<<res;
else
throw 0;
catch(int unit){
cout<<"Incomplete Data";
return 0;
}
#include <iostream>
int main()
int n,m,a;
try{
cin>>n>>m>>a;
if(cin){
cout<<((n+a-1)/a)*((m+a-1)/a);
else
throw 0;
catch(int dimension){
cout<<"Invalid Dimension";
return 0;
}
#include<bits/stdc++.h>
int main(){
int t,i,j;
cin>>t;
string str;
f(j,0,t){
f(i,0,2){
try{
cin>>str[i];
if(isalpha(str[i]))
cout<<str[i]<<" is alphabetic"<<endl;
else
throw str[i];
}
#include <iostream>
int main()
int a,b,c;
try{
cin>>a>>b>>c;
if(cin){
cout<<2*(a*b+b*c+c*a);
else
throw 0;
catch(int objectinfo){
return 0;
}
#include <iostream>
class Employee{
public:
};
public:
int code,basic,hra,da,pf,total;
string name,position;
void getEmpDetails(){
cin>>code>>name>>position;
void getPayDetails(){
cin>>basic>>hra>>da>>pf;
void calculate(){
total=basic+hra+da-pf;
void display(){
cout<<"Employee Number:"<<code<<endl;
cout<<"Employee Name:"<<name<<endl;
cout<<"Employee Role:"<<position<<endl;
};
int main()
Salary s;
s.getEmpDetails();
s.getPayDetails();
s.calculate();
s.display();
return 0;
#include <iostream>
class Person{
};
};
public:
int id;
string name,group,staff;
void accept_instructor_details(){
cin>>id>>name>>group>>staff;
void display_instructor_details(){
cout<<"Id:"<<id<<endl;
cout<<"Name:"<<name<<endl;
cout<<"Group:"<<group<<endl;
cout<<"Staff:"<<staff<<endl;
};
int main()
int n;
cin>>n;
Instructor inst[n];
for(int i=0;i<n;i++){
inst[i].accept_instructor_details();
inst[i].display_instructor_details();
return 0;
cout<<"Instructor *inst;";
}
#include <iostream>
class acc{
public:
int no;
void getacc(){
cin>>no;
};
public:
string name;
int code;
void getbranch(){
cin>>name>>code;
void display(){
cout<<"Acc No:"<<no<<endl;
cout<<"Name:"<<name<<endl;
cout<<"Branch Code:"<<code<<endl;
};
int main()
{
branch b;
b.getacc();
b.getbranch();
b.display();
return 0;
#include <iostream>
class Food{
};
};
public:
float cal,fat;
void calorie(){
cin>>cal>>fat;
void dplan(){
if(cal<fat)
};
int main()
Patient p;
p.calorie();
p.dplan();
return 0;
#include <iostream>
class Sam{
};
public:
int rows;
rows=y;
void display(){
for(int i=0;i<rows;i++){
for(int j=0;j<rows;j++){
cout<<"* ";
cout<<endl;
};
int main()
Robin obj;
int y;
cin>>y;
obj.read(y);
obj.display();
return 0;
#include <iostream>
class student{
public:
int roll,m1,m2;
void get(){
cin>>roll>>m1>>m2;
};
class sports{
public:
int sp;
void getsm(){
cin>>sp;
};
public:
void display(){
cout<<"Roll No:"<<roll<<endl;
cout<<"Total:"<<m1+m2+sp<<endl;
cout<<"Average:"<<(m1+m2+sp)/3<<endl;
};
int main()
statement obj;
obj.get();
obj.getsm();
obj.display();
return 0;
}
#include <iostream>
class Shape{
public:
int len,wid;
len=l;
wid=b;
};
public:
void output(){
cout<<len*wid<<endl;
};
public:
void output(){
//if((len*wid)%2==0)
cout<<0.5*len*wid<<endl;
//else
//cout<<len*wid/2+1<<endl;
}
};
int main()
int l,b;
cin>>l>>b;
Rectangle rect;
Triangle tri;
rect.input(l,b);
tri.input(l,b);
rect.output();
tri.output();
return 0;
#include <iostream>
class customer{
public:
int no;
string name;
void acceptc(){
cin>>name>>mobile>>no;
};
public:
int bal;
void acceptd(){
cin>>bal;
void dispd(){
cout<<"Customer Name:"<<name<<endl;
cout<<"Balance:"<<bal<<endl;
};
public:
void acceptb(){
cin>>loan_no>>amt;
void dispb(){
cout<<"Loan No:"<<loan_no<<endl;
cout<<"Loan Amount:"<<amt<<endl;
};
int main()
int n;
cin>>n;
borrow b1[n];
for(int i=0;i<n;i++){
b1[i].acceptc();
b1[i].acceptd();
b1[i].acceptb();
b1[i].dispd();
b1[i].dispb();
return 0;
#include <iostream>
class Receive{
public:
int r1,i1,r2,i2,r3,i3;
void getdata(){
cin>>r1>>i1>>r2>>i2;
};
public:
void add(){
r3=r1+r2;
i3=i1+i2;
};
public:
void output(){
cout<<r1<<"+"<<i1<<"i"<<endl;
cout<<r2<<"+"<<i2<<"i"<<endl;
cout<<r3<<"+"<<i3<<"i"<<endl;
};
int main()
Present calc;
calc.getdata();
calc.add();
calc.output();
return 0;
#include <iostream>
class Person{
};
};
public:
int n1,n2,basic,hra,da,pf;
string name1,role1,col,ifsc,name2,role2;
void getdetail(){
cin>>n1>>name1>>role1>>col>>ifsc>>n2>>name2>>role2;
void getEmployeeDetails(){
cin>>basic>>hra>>da>>pf;
void student_display(){
cout<<"Person number:"<<n1<<endl;
cout<<"Person name:"<<name1<<endl;
cout<<"Person Role:"<<role1<<endl;
cout<<"Student IFSC:"<<ifsc<<endl;
cout<<"Person number:"<<n2<<endl;
cout<<"Person name:"<<name2<<endl;
cout<<"Person Role:"<<role2<<endl;
void employee_display(){
cout<<"Employee HRA:"<<hra<<endl;
cout<<"Employee DA:"<<da<<endl;
cout<<"Employee PF:"<<pf<<endl;
};
int main()
Student e;
e.getdetail();
e.getEmployeeDetails();
e.student_display();
e.employee_display();
return 0;
cout<<"s.student_display();";
}
INPUT OUTPUT:-
#include <iostream>
int main()
int r,s,cpool,spool;
cin>>r>>s;
cpool=3.14*r*r;
spool=s*s;
if(cpool>spool)
else
return 0;
}
#include <iostream>
int main()
int aravspeed,aaronspeed,speeddiff;
cin>>aravspeed>>aaronspeed;
if(aravspeed>aaronspeed)
speeddiff=aravspeed - aaronspeed;
else
speeddiff=aaronspeed - aravspeed;
cout<<speeddiff;
return 0;
}
#include <iostream>
int main() {
int bro1,bro2,bro3;
cin>>bro1>>bro2>>bro3;
if(bro1>bro2) {
if(bro1>bro3)
cout<<bro1;
else
cout<<bro3;
else if(bro2>bro3)
cout<<bro2;
else
cout<<bro3;
return 0;
}
#include <iostream>
int main()
int n,dig=0,rem;
cin>>n;
while(n!=0)
rem=n%10;
dig=dig*10+rem;
n/=10;
while(dig!=0)
rem=dig%10;
switch(rem)
{
case 0:
cout<<"Zero ";
break;
case 1:
cout<<"One ";
break;
case 2:
cout<<"Two ";
break;
case 3:
cout<<"Three ";
break;
case 4:
cout<<"Four ";
break;
case 5:
cout<<"Five ";
break;
case 6:
cout<<"Six ";
break;
case 7:
cout<<"Seven ";
break;
case 8:
cout<<"Eight ";
break;
case 9:
cout<<"Nine ";
break;
};
dig/=10;
return 0;
#include <iostream>
int main()
int number,num,rem,result=0;
cin>>number;
num=number;
while(num!=0) {
rem = num%10;
result+=rem*rem*rem;
num/=10;
if(result==number)
else
return 0;
#include <iostream>
int main()
int nooffamilymembers,i,j;
cin>>nooffamilymembers;
for(i=nooffamilymembers;i>0;i--)
{
for(j=0;j<i;j++)
cout<<i<<" ";
cout<<endl;
return 0;
#include <iostream>
int main()
int t,n,h,i,l=1,count;
cin>>t;
while(t--)
l=1;
count=0;
cin>>n;
for(i=1;i<=n;i++) {
cin>>h;
if(h==l) {
count+=2;
if(h>l) {
l=h;
count++;
cout<<count<<endl;
return 0;
#include <iostream>
int main()
{
int M,initialtemp,finaltemp;
float Q;
cin>>M>>initialtemp>>finaltemp;
Q=M*(finaltemp - initialtemp)*4184;
cout<<""<<Q;
return 0;
#include <iostream>
int main()
int husage,wfage,coupleavgage;
cin>>husage>>wfage;
coupleavgage=(husage+wfage)/2;
return 0;
}
#include <iostream>
int main()
int weightinearth;
cin>>weightinearth;
float weightinmoon;
weightinmoon=0.166*weightinearth;
cout<<weightinmoon;
return 0;
}
#include <iostream>
class Happiness{
public:int Meat(){
int n,a,b,max=100,sum=0;
cin>>n;
while(n--)
cin>>a>>b;
//max=b;
if(b>=max)
sum+=a*max;
// cout<<max<<endl;
// cout<<sum<<endl;
else
max=b;
sum+=a*b;
// cout<<max<<endl;
// cout<<sum<<endl;
return sum;
};
int main(){
Happiness Purchase;
cout<<Purchase.Meat();
}
#include <iostream>
#include <string.h>
#include <stdio.h>
int fun(int x) {
int s = 0;
while (x)
s += x & 1;
x >>= 1;
return s;
int main() {
if(0)
int n, i, r, t, j;
cin >> n;
scanf("%lf", &a[i][j]);
memset(b, 0, sizeof(b));
b[(1 << n) - 1] = 1;
int c = fun(i);
c = c * (c - 1) / 2;
#include <iostream>
#include<cstring>
#include<string>
class aadhaar
public:
{
if(fn.empty() || mn.empty() || ln.empty() )
cout<<"Invalid Name";
else
cout<<fn<<mn<<ln;
};
int main()
aadhaar Card;
string fn,mn,ln;
cin>>fn>>mn>>ln;
Card.NameofCitizen(fn,mn,ln);
return 0;
}
#include <iostream>
class TollBooth
public:
int cars;
float tollcollected;
TollBooth(){
cars=0;
tollcollected=0;
cars++;
tollcollected+=pay;
void nonpayingcar(){
cars++;
void display(){
cout<<cars<<endl<<tollcollected<<endl;
};
int main()
TollBooth obj;
char VehicleNo[10];
float TollAmt;
int carpassed,i;
cin>>carpassed;
for(i=0;i<carpassed;i++)
{
cin>>VehicleNo>>TollAmt;
if(TollAmt>0) obj.payingcar(TollAmt);
else obj.nonpayingcar();
obj.display();
return 0;
#include <bits/stdc++.h>
//#include<iomanip>
//#include<string>
class student
string name;
int roll;
float height,weight;
public:
student(){name="Bhagavan";roll=1593;height=172.5;weight=60.4;}
void getdata() {
cin>>name>>roll>>height>>weight;
void displaydata(){
};
int main()
student s1,s2;
s1.getdata();
s1.displaydata();
s2.displaydata();
return 0;
#include <iostream>
using namespace std;
class Friends
public:void Gifts(){
int i, n, a, b[50] = { 0 };
cin >> n;
cin >> a;
b[a] = i;
};
int main()
Friends Sharing;
Sharing.Gifts();
}
#include<bits/stdc++.h>
class Drinks{
int n,a,b,c,t,ans=0;
public:void Shop(){
cin>>n>>a>>b>>c;
void display(){
for(int i=0;i<=b;i++)
for(int j=0;j<=c;j++)
if(2*(n-i-j*2)>=0&&2*(n-i-j*2)<=a)
ans++;
cout<<ans;
};
int main(){
Drinks Buy;
Buy.Shop();
Buy.display();
}
#include <bits/stdc++.h>
class IndianArmy
public:int ResumesofCamdidates(){
long long n;
cin>>n;
cout<<k+k*(n-5)/6+k*(n-5)*(n-6)/42;
return 1;
};
int main(){
IndianArmy GroupingofResumes;
GroupingofResumes.ResumesofCamdidates();
return 0;
}
#include <iostream>
class ITEM
public:
int n;
float large=0,summ=0;
float arr[100],code[100];
n=b;
for(int i=0;i<n;i++)
cin>>code[i]>>arr[i];
void largest(){
for(int i=0;i<n;i++)
{
if(arr[i]>=large)
large=arr[i];
void sum(){
for(int i=0;i<n;i++)
summ+=arr[i];
void displayitems(){
cout<<"Largest Price="<<large<<endl;
cout<<"Sum of Prices="<<summ<<endl;
for(int i=0;i<n;i++)
};
int main()
ITEM order;
int b;
cin>>b;
order.getdata(b);
order.largest();
order.sum();
order.displayitems();
return 0;
}
#include<iostream>
class Complex{
public:
int r1,i1,r2,i2,r3,i3;
Complex(){cin>>r1>>i1;cin>>r2>>i2;}
void addcomplex(){
r3=r1+r2;
i3=i1+i2;
void displaycomplex(){
cout<<r1<<"+"<<i1<<"i"<<endl;
cout<<r2<<"+"<<i2<<"i"<<endl;
cout<<r3<<"+"<<i3<<"i"<<endl;
};
int main(){
Complex calculate;
calculate.addcomplex();
calculate.displaycomplex();
return 0;
Constructor Overloading:-
#include <iostream>
class Student
public:
cout<<name<<" "<<id<<endl;
}
cout<<name<<" "<<id<<endl;
};
int main()
Student Details;
string name;
int id;
cin>>name>>id;
Details.Identity(name,id);
cin>>id>>name;
Details.Identity(id,name);
return 0;
}
#include <iostream>
class Store{
public:
cout<<id<<endl;
cout<<totalavl - consumed<<endl;
};
int main()
Store purchase;
int id,totalavl,consumed;
cin>>id>>totalavl>>consumed;
purchase.itemcount(id);
purchase.itemcount(totalavl,consumed);
return 0;
}
#include<bits/stdc++.h>
int i,n,a,mx=INT_MIN,c[1000];
int main(){
cin>>n;
mx=res(n);
cout<<dis(n,mx);
return 0;
for(i=0;i<n;i++){
cin>>a;
c[a]++;
mx=max(mx,c[a]);
return mx;
}
return mx+1;
return mx;
if(n%mx==2)
return mx+1;
return mx;
#include <iostream>
class Hospital{
public:
cout<<mdeicinebill*days<<endl;
}
void bill(int roomrent,int days){
cout<<roomrent*days;
};
int main()
Hospital ob;
int roomrent;
cin>>mdeicinebill>>days;
ob.bill(mdeicinebill,days);
cin>>roomrent>>days;
ob.bill(roomrent,days);
return 0;
#include<bits/stdc++.h>
int i,T,a,b,c,n;
public:
void get(){
std::cin>>a>>b>>c;
n=2*abs(a-b);
void get2(){
if(c>n||max(a,b)>n)
cout<<"-1"<<endl;
else if(c>n/2)
cout<<c-n/2<<endl;
else
cout<<c+n/2<<endl;
};
int main(){
cin>>T;
solve p;
f(i,0,T){
p.get();
p.get2();
return 0;
}
#include <iostream>
class Olympic{
public:
cout<<D1+D2<<" meters"<<endl;
cout<<D3+D4+D5<<" meters"<<endl;
};
int main()
Olympic Medal;
int D1,D2,D3,D4,D5;
cin>>D1>>D2>>D3>>D4>>D5;
Medal.distance(D1,D2);
Medal.distance(D3,D4,D5);
return 0;
#include <iostream>
int main()
int t;
cin>>t;
while(t--){
int n,odd=0;
cin>>n;
int z=power(n,odd);
//cout<<n<<z;
power(n,z,1);
return 0;
}
int a[2*x];
for(int i=0;i<2*x;i++){
cin>>a[i];
if(a[i]%2==1)
p++;
return p;
if(x==y)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 1;
}
#include <iostream>
class AccBalance{
public:
AccBalance(){cout<<"Zero Balance"<<endl;}
AccBalance(int balance){
if(balance<0)
else if(balance==0)
else
};
int main()
AccBalance defltBal;
int balance;
cin>>balance;
AccBalance currBal(balance);
return 0;
}
#include <iostream>
class Country{
public:
Country(){cout<<"Country:INDIA"<<endl;}
cout<<"State:"<<statename<<endl<<"Area:"<<area<<endl<<"Density:"<<density<<endl;
};
int main()
Country country;
char statename[100];
int area,density;
cin>>statename>>area>>density;
Country statesofindia(statename,area,density);
return 0;
}
#include <iostream>
class Welcomemsg{
public:
cout<<"Hi "<<fname<<endl;
};
int main()
Welcomemsg ob;
string fname,lname;
cin>>fname;
ob.msg(fname);
cin>>fname>>lname;
ob.msg(fname,lname);
return 0;
Operator Overloading:-
#include <iostream>
class Fraction{
public:
int num,den;
num=n;
den=d;
res.num=num * obj.den;
res.den=den * obj.num;
return res;
void display1(){
cout<<num/den;
void display2(){
cout<<num<<"/"<<den;
void display3(){
cout<<"Error";
};
int main()
int a,b,c,d;
cin>>a>>b;
cin>>c>>d;
if(ob1.den==0 || ob2.den==0){
cout<<"Error";
return 0;
if(ob3.den==1)
ob3.display1();
else{
for(int i=2;i<50;i++)
ob3.num=ob3.num/i;
ob3.den=ob3.den/i;
}
ob3.display2();
return 0;
#include <iostream>
class Time
int h,m,s;
public:
Time()
cin>>h>>m>>s;
void check()
};
return true;
else
return false;
int main()
Time t1,t2;
t1.check();
t2.check();
if(t1==t2)
else
return 0;
}
#include <iostream>
class Scrum{
public:
int n;
Scrum(int h)
n=h;
--n;
return 1;
void display(){
int res=1;
for(int i=1;i<=n;i++){
res=res*i;
cout<<res;
};
int main()
int n;
cin>>n;
Scrum T(n);
T--;
T.display();
return 0;
#include<iostream>
class Fraction
public:
int num,den;
Fraction()
num=0;
den=0;
}
void getinput()
cin>>num>>den;
Fraction temp;
temp.num=(num*obj.den)+(den*obj.num);
temp.den=den*+obj.den;
return temp;
};
int main()
Fraction f1,f2,add;
f1.getinput();
f2.getinput();
add=f1+f2;
if(add.den==0)
cout<<"Error";
else if(add.num%add.den == 0)
cout<<add.num/add.den;
else
cout<<add.num<<"/"<<add.den;
return 0;
}
#include <iostream>
class matrix{
public:
int a,b,c,d;
cin>>a>>b>>c>>d;
return a*d-b*c;
};
int main()
matrix t;
cout<<~t;
return 0;
}
#include<iostream>
class Complex {
private:
public:
Complex operator+(int a) {
Complex res;
res.real = real + a;
res.imag = imag;
return res;
Complex res;
return res;
void print() { cout << real << " + " << imag <<"i"<< endl; }
};
int main()
int a,b,c;
cin>>a>>b>>c;
Complex i2 = i1 + c;
i1.print();
i2.print();
(i1+i2).print();
#include<iostream>
class compare{
public:
int first,sum1=0;
compare(int x){
first=x;
void f(){
//first1=first;
for(int i=1; i<=first/2 ; i++)
if(first%i==0)
sum1=sum1+i;
cout<<"Friendly Pair";
else
};
//main program
int main()
int first,second;
//user input
cin>>first;
//user input
cin>>second;
compare t1(first),t2(second);
t1.f();
t2.f();
t1==t2;
return 0;
}
#include <iostream>
class Diff{
public:
int n;
void getdata(){
cin>>n;
int sumofsquare();
int sumofnumsq(){
return n*(n+1)*(2*n+1)/6;
};
return n*n*(n+1)*(n+1)/4;
int main()
Diff n;
if(0)
//int sq=n*n*(n+1)*(n+1)/4;
//int sq2=n*(n+1)*(2*n+1)/6;
cout<<n.sumofsquare()-n.sumofnumsq();
return 0;
#include <iostream>
class complex
private:
float real;
float imag;
public:
complex() {cin>>real>>imag;}
complex t;
return t;
}
void output()
if(imag < 0)
else
};
int main()
c1.output();
c2.output();
(c1 - c2).output();
return 0;
#include<iostream>
class Fraction
{
public:
int num,den;
Fraction()
num=0;
den=0;
void getinput()
cin>>num>>den;
Fraction temp;
temp.num=(num*obj.den)-(den*obj.num);
temp.den=den*+obj.den;
return temp;
};
int main()
Fraction f1,f2,add;
f1.getinput();
f2.getinput();
add=f1-f2;
if(add.den==0)
cout<<"Error";
else if(add.num%add.den == 0)
cout<<add.num/add.den;
else
cout<<add.num<<"/"<<add.den;
return 0;
}
Inheritance:-
#include <iostream>
class staff{
public:
int code,speed;
string name;
void getdata();
void display();
};
void staff::getdata(){
cin>>name>>code>>speed;
void staff::display(){
cout<<"Name:"<<name<<endl<<"Code:"<<code<<endl<<"Speed"<<speed;
public:
void getdata();
void display();
};
void typist::getdata(){
cin>>name>>code>>speed;
void typist::display(){
cout<<"Name:"<<name<<endl<<"Code:"<<code<<endl<<"Speed:"<<speed;
int main()
typist t;
t.getdata();
t.display();
return 0;
#include <iostream>
using namespace std;
class Assignement{
public:
int num;
void get(){
cin>>num;
void display(){
int count=0;
while(num!=0){
count++;
num/=10;
cout<<count;
};
};
int main()
Student obj;
obj.get();
obj.display();
return 0;
}
#include <iostream>
class market{
public:
float i1,i2,i3,i4,i5;
float Subtotal,tax;
void items(){
cin>>i1>>i2>>i3>>i4>>i5;
void buy(){
Subtotal=(i1+i2+i3+i4+i5);
cout<<"Subtotal=$"<<Subtotal<<endl;
tax=0.06*i1+0.06*i2+0.06*i3+0.06*i4+0.06*i5;
cout<<"Tax=$"<<tax<<endl;
cout<<"Total=$"<<Subtotal+tax;
};
int main()
customer c;
c.items();
c.buy();
#include <iostream>
class ReceiveMesurement{
public:
int l,b;
void painingarea(){
cin>>l>>b;
cout<<l*b*27;
}
};
};
int main()
CalculateArea mt;
mt.painingarea();
return 0;
#include <iostream>
class Bank{
public:
int n;
void get(){
cin>>n;
void display(){
cout<<"500: "<<n/500<<endl;
n=n%500;
cout<<"200: "<<n/200<<endl;
n=n%200;
cout<<"100: "<<n/100<<endl;
n=n%100;
cout<<"50: "<<n/50<<endl;
n=n%50;
cout<<"10: "<<n/10<<endl;
n=n%10;
cout<<"5: "<<n/5<<endl;
n=n%5;
cout<<"1: "<<n<<endl;
};
};
int main()
CashCounting obj;
obj.get();
obj.display();
return 0;
}
#include <iostream>
class ReceiveMesurement{
public:
int l,b;
void display(){
cin>>l>>b;
cout<<"Length:"<<l<<" metres"<<endl;
cout<<"Breadth:"<<b<<" metres";
};
};
int main()
FormatMesurement mt;
mt.display();
return 0;
}
#include <bits/stdc++.h>
class graph{
public:
void edge(){
};
public:
void vertex(){
cin>>n>>m;
cout<<max(0ll,n-2*m)<<" ";
while(k*(k-1)/2<m) k++;
cout<<n-k<<endl;
};
int main()
pairs pa;
pa.edge();
pa.vertex();
return 0;
#include <iostream>
class triangle{
public:
int a,b,c;
void read(){
cin>>a>>b>>c;
void check(){
else
cout<<"NOT ISOSCELES";
};
};
int main()
isosceles obj;
obj.read();
obj.check();
return 0;
#include <iostream>
class doctor{
public:
string name,degree,pname;
int no;
void getedu(){
cin>>name>>degree>>pname;
void getdata(){
cin>>no;
void dispedu(){
void dispdata(){
cout<<"Bed Number:"<<no;
};
};
int main()
patient p;
p.getedu();
p.getdata();
p.dispedu();
p.dispdata();
return 0;
}
#include <iostream>
class teacher{
public:
int num;
void setdata(int n)
if(n==1)
num=10;
else
num=7;
void setdata2(int n)
if(n==2)
num=3;
else
num=8;
}
void tentable(){
for(int i=1;i<=10;i++)
cout<<num<<"*"<<i<<"="<<num*i<<endl;
};
};
};
};
};
int main()
int n;
cin>>n;
teacher t;
if(n==1 || n==4)
t.setdata(n);
if(n==2 || n==3)
t.setdata2(n);
t.tentable();
return 0;
class School{
public:
int roll;
string name;
};
void getdata();
void display();
};
cin>>roll>>name;
}
int main()
District obj;
School* ptr;
ptr = &obj;
return 0;
#include <bits/stdc++.h>
int a,b,c,d,i;
class Holiday{
};
public:
void Expenses(){
cin>>c;
cin>>a;
if (d<a) d=a;
b=b+a;
cout<<d*c-b;
};
Citizen obj;
obj.Expenses();
return 0;
#include <bits/stdc++.h>
using namespace std;
class Employees{
};
public:
int n;
void BuyingGame(){
cin>>n;
cout<<n - n / 2 - n / 3 - n / 5 - n / 7
+ n / 6 + n / 10 + n / 14 + n / 15 + n / 21 + n / 35
- n / 30 - n / 42 - n / 70 - n / 105 + n / 210;
};
int main()
Reward obj;
obj.BuyingGame();
return 0;
}
#include <iostream>
class Employee{
public:
int s1,s2;
};
public:
void getSalary(){
cin>>s1;
cout<<"Salary of Developer:"<<s1<<endl;
};
public:
void getSalary(){
cin>>s2;
cout<<"Salary of Driver:"<<s2<<endl;
}
};
int main()
Developer d1;
Driver d2;
d1.getSalary();
d2.getSalary();
return 0;
#include <iostream>
class consumer{
public:
string name;
};
int code;
long tel;
int quan,price;
void getdata(){
cin>>name>>code;
cin>>tel;
cin>>quan;
cin>>price;
void display(){
};
int main()
consumer* o1;
transaction o2;
o1=&o2;
o1->getdata();
o1->display();
return 0;
}
#include<iostream>
class Problem {
};
public:
int n,k,i;
void Divisor(){
cin>>n>>k;
int Display()
int count;
for(i=1;i<=n;++i)
if(n%i==0)
count++;
if(count==k){
cout<<i;
return 1;
cout<<-1;
return 1;
};
int main()
Calculation obj;
obj.Divisor();
obj.Display();
return 0;
#include <iostream>
using namespace std;
class Gift {
};
public:
int a[10],n;
void Cubes(){
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n/2;i+=2)
/*int temp=a[i];
a[i]=a[n-i-1];
a[n-i-1]=temp;*/
swap(a[i],a[n-i-1]);
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
};
int main()
Birthday obj;
obj.Cubes();
return 0;
}
#include <iostream>
#include<string>
class Decode{
};
public:
string s1,s2;
int n;
void Convert(){
cin>>n>>s1;
for(int i=0;i<n;i++){
if((n-i)%2==1)
s2=s2+s1[i];
else
s2=s1[i]+s2;
cout<<s2;
}
};
int main()
Word obj;
obj.Convert();
#include <iostream>
class country
public:
};
{
public:
char a[20];
int b,c;
char d[20];
int e,f;
void getdata(){
cin>>a>>b>>c>>d>>e>>f;
void display()
};
int main() {
if(0)
cout<<"country::getdata();";
country *o1;
state o2;
o1=&o2;
o1->getdata();
o2.display();
return 0;
}
#include<iostream>
class Smartphone{
};
public:
int T,S,q,c=0;
void Listening(){
cin>>T>>S>>q;
while(S<T){
c++;
S*=q;
cout<<c;
};
int main()
{
LoveForMusic obj;
obj.Listening();
return 0;
Templates:-
#include <bits/stdc++.h>
if(a>b)
cout<<"Kayal\n";
else
cout<<"Elavenil\n";
return 1;
int main()
int a,b;
cin>>a>>b;
if(a%(a-b)==0 && b%(a-b)==0)
cout<<"Equal\n";
else
Visit(a,b);
return 0;
#include <iostream>
t = t*k*n/100.0;
while(n--){
cout<<min(t,k)<<" ";
t-=min(t,k);
return 1;
int main()
{
int n,k,t;
cin>>n>>k>>t;
Bar(n,k,t);
return 0;
#include <iostream>
cout<<player2<<" "<<player1;
int main()
string player1,player2;
cin>>player1>>player2;
InterchangeFavPlayers(player1,player2);
return 0;
}
#include <iostream>
#include<cmath>
int c;
c=sqrt(x*x+y*y);
if(c*c==x*x+y*y){
cout<<"black\n";
return 0;
if(x*y<0)
c++;
if(c%2==0)
cout<<"black";
else cout<<"white";
return 1;
int main()
{
int x,y;
cin>>x>>y;
MagicClocl(x,y);
return 0;
#include <iostream>
cout<<((b+c-1)/c)*((a+c-1)/c);
return 1;
int main()
int a,b,c;
cin>>a>>b>>c;
Rome(a,b,c);
return 0;
}
#include <iostream>
if(T%2==0)
return 4*T+1;
else if(T%4==1)
return 2*T+1;
else
return T+1;
int main()
int T,n;
cin>>T;
while(T--){
cin>>n;
cout<<Square(n)<<endl;
return 0;
}
#include <iostream>
int c=0;
for(int i=0;i<=d;i++){
if(i%k==0||i%l==0||i%m==0||i%n==0)
c++;
return c-1;
int main()
int k,l,m,n,d;
cin>>k>>l>>m>>n>>d;
cout<<Counting(k,l,m,n,d);
return 0;
}
#include <iostream>
if(x1==x2 || y1 == y2 || z1==z2)
cout<<"YES";
else
cout<<"NO";
return 1;
int main()
int x1,y1,z1,x2,y2,z2;
cin>>x1>>y1>>z1>>x2>>y2>>z2;
Planet(x1,y1,z1,x2,y2,z2);
return 0;
}
#include<bits/stdc++.h>
int d=1,e,i,j;
for(i=0;i<=4000;i++)
for(j=0;j<=4000;j++) {
e=n-a*i-b*j;
if(e>=0&&e%c==0)
d=max(d,i+j+e/c);
cout<<d;
return 1;
int main(){
int n,a,b,c;
cin>>n>>a>>b>>c;
Pieces(n,a,b,c);
}
#include <iostream>
template<class T>
T DivideMangosteen(T PurchasedWeight){
if(PurchasedWeight%2==0)
cout<<"YES";
else
cout<<"NO";
return 1;
int main()
int PurchasedWeight;
cin>>PurchasedWeight;
DivideMangosteen(PurchasedWeight);
return 0;
Exceptional Handling:-
#include <iostream>
int main()
string str1,str2;
try{
cin>>str1>>str2;
if(cin){
for(int i=0;i<n;i++){
throw 0;
if(str1[i]==str2[i])
count++;
if(count!=n)
else
cout<<str1<<" is "<<str2;
cout<<"Inappropriate Input";
}
return 0;
#include <bits/stdc++.h>
#include <string.h>
int main()
int k;
try{
cin>>k;
if(cin)
cout<<fixed<<setprecision(0)<<tgamma(k+1);
else
throw "e";
return 0;
#include <iostream>
int main()
int n,m;
try{
cin>>n;
cin>>m;
if(cin){
cout<<n-1+(1+2*(n-1))*(m-1);
else
throw 0;
catch(int griddimensions)
}
return 0;
#include<bits/stdc++.h>
int main()
float hour,salaryperday;
try{
cin>>hour;
cin>>salaryperday;
if(cin){
cout<<fixed<<setprecision(2)<<hour*salaryperday;
else
throw 0;
catch(int workstatus)
return 0;
}
#include <iostream>
int main()
int donuts,milk;
try{
cin>>donuts;
cin>>milk;
if(milk==0)
throw donuts;
else
catch(int e){
return 0;
}
#include <iostream>
#include <math.h>
int main()
int a;
try {
cin>>a;
cout<<"Valid Mark";
else
throw "e";
cout<<"Invalid Mark";
}
#include <bits/stdc++.h>
int main()
int unitconsumed,costperunit;
try{
cin>>unitconsumed;
cin>>costperunit;
res=pow(unitconsumed,costperunit);
if(cin){
cout<<res;
else
throw 0;
catch(int unit){
cout<<"Incomplete Data";
return 0;
}
#include <iostream>
int main()
int n,m,a;
try{
cin>>n>>m>>a;
if(cin){
cout<<((n+a-1)/a)*((m+a-1)/a);
else
throw 0;
catch(int dimension){
cout<<"Invalid Dimension";
return 0;
}
#include<bits/stdc++.h>
int main(){
int t,i,j;
cin>>t;
string str;
f(j,0,t){
f(i,0,2){
try{
cin>>str[i];
if(isalpha(str[i]))
cout<<str[i]<<" is alphabetic"<<endl;
else
throw str[i];
}
#include <iostream>
int main()
int a,b,c;
try{
cin>>a>>b>>c;
if(cin){
cout<<2*(a*b+b*c+c*a);
else
throw 0;
catch(int objectinfo){
return 0;
}
STL:-
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
int N, a, b;
while (cin>>N) {
vector<pair<int,pair<int,int>>>StorageDrives;
cin>>a>>b;
sort(StorageDrives.begin(),StorageDrives.end());
int z=StorageDrives.size();
cap = StorageDrives[i].second.first;
#include<bits/stdc++.h>
int n,m,sx=99999,sy=99999,x,y;
char a[55][55];
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
if(a[i][j]=='*'){
x=max(x,i),y=max(y,j),sx=min(sx,i),sy=min(sy,j);
}
}
for(int i=sx;i<=x;i++){
cout<<endl;
return 0;
cout<<"vector<vector<char>>drawing(n,vector<char>(m,'0')); drawing[row][col]";
#include <bits/stdc++.h>
LL n, k, v, idx;
string name[N];
int main(){
LL t; cin>>t; while(t--){
cin>>n>>k>>v;
cin>>name[i];
LL st=((v-1)*k)%n;
//cout<<"Case #"<<(++idx)<<":";
vector<int> ans;
ans.push_back((st+i)%n);
sort(ans.begin(), ans.end());
cout<<name[id]<<" ";
cout<<"\n";
return 0;
#include <bits/stdc++.h>
int main()
int n;
cin>>n;
set<pair<string,string>>Descriptionofleaves;
string species,color;
while(n--){
cin>>species>>color;
Descriptionofleaves.insert(make_pair(species,color));
cout<<Descriptionofleaves.size();
return 0;
#include <bits/stdc++.h>
void sum(){}
int n,m;
int cost[2020];
string g[1010];
int main()
cin>>n>>m;
for(int i=0;i<n;i++)
cin>>g[i];
for(int j=0;j<m;j++)
{
if(g[i][j]=='#')
use[i].push_back(j+n);
use[j+n].push_back(i);
queue<int>BankChamber;
BankChamber.push(n-1);
cost[n-1]=1;
while(!BankChamber.empty())
int t=BankChamber.front();
BankChamber.pop();
int z=use[t].size();
for(int i=0;i<z;i++)
if(cost[use[t][i]]==0)
cost[use[t][i]]=cost[t]+1;
BankChamber.push(use[t][i]);
cout<<cost[0]-1<<endl;
sum();
return 0;
cout<<"BankChamber.push(n);";
}
#include<bits/stdc++.h>
ll a[100006],c[3];
int main()
ll n,m,i,j,k,l,sum=0;
cin>>n>>m;
for(i=0;i<m;i++)
sum=0;
for(j=0;j<3;j++)
cin>>c[j];
sum=sum+a[c[j]];
l=1;
for(k=0;k<3;k++)
if(l==sum)
l++;
if(a[c[k]]==0)
{
a[c[k]]=l++;
for(i=1;i<=n;i++)
cout<<a[i]<<" ";
return 0;
cout<<"map<int,int>dance; set<int>dancer;";}
#include <bits/stdc++.h>
int main(){
int t;
cin >> t;
while (t--) {
int n, d;
map<ll, vector<pair<long,long>>>TGS;
TGS[day].push_back({sad, lec}); }
priority_queue<pair<long,long>>PQ;
PQ.push(x);
if (!PQ.empty())
PQ.pop();
p.second--;
if (p.second == 0) {}
else
PQ.push({p.first, p.second});
ll cnt = 0;
while (!PQ.empty()) {
PQ.pop();
return 0;
deque<char>Operations(20);
if((int)a.size()==1){
ans=min(ans,a[0]);
return;
for(int i=0;i<(int)a.size();i++){
for(int j=0;j<i;j++){
vector<long long> b;
if(Operations[id]=='+') b.push_back(a[i]+a[j]);
else b.push_back(a[i]*a[j]);
for(int k=0;k<(int)a.size();k++){
solve(b,id+1);
}
int main() {
vector<long long>numbers(4);
solve(numbers,0);
cout<<ans;
return 0;
#include <bits/stdc++.h>
int i,j,n,x[110],d[110];
int main(){
cin>>n;
f(i,1,n+1) cin>>x[i]>>d[i];
f(i,1,n+1){
f(j,i+1,n+1){
return 0;
}
}
return 0;
#include<bits/stdc++.h>
int i,n;
string s,t,u;
int D()
for(i=0;s[i];i++)if(s[i]^t[i])return 0;
return 1;
int main()
for(cin>>s>>n;n--;)
cin>>t;
if(D()&&(u.empty()||t<u))u=t;
}
if(u.empty())cout<<s;
else cout<<u;
return 0;
Advanced Inheritance:-
#include <iostream>
class Employee{
public:
};
public:
int code,basic,hra,da,pf,total;
string name,position;
void getEmpDetails(){
cin>>code>>name>>position;
void getPayDetails(){
cin>>basic>>hra>>da>>pf;
void calculate(){
total=basic+hra+da-pf;
void display(){
cout<<"Employee Number:"<<code<<endl;
cout<<"Employee Name:"<<name<<endl;
cout<<"Employee Role:"<<position<<endl;
};
int main()
Salary s;
s.getEmpDetails();
s.getPayDetails();
s.calculate();
s.display();
return 0;
}
#include <iostream>
class Person{
};
};
public:
int id;
string name,group,staff;
void accept_instructor_details(){
cin>>id>>name>>group>>staff;
void display_instructor_details(){
cout<<"Id:"<<id<<endl;
cout<<"Name:"<<name<<endl;
cout<<"Group:"<<group<<endl;
cout<<"Staff:"<<staff<<endl;
};
int main()
int n;
cin>>n;
Instructor inst[n];
for(int i=0;i<n;i++){
inst[i].accept_instructor_details();
inst[i].display_instructor_details();
return 0;
cout<<"Instructor *inst;";
#include <iostream>
class acc{
public:
int no;
void getacc(){
cin>>no;
};
public:
string name;
int code;
void getbranch(){
cin>>name>>code;
void display(){
cout<<"Acc No:"<<no<<endl;
cout<<"Name:"<<name<<endl;
cout<<"Branch Code:"<<code<<endl;
};
int main()
branch b;
b.getacc();
b.getbranch();
b.display();
return 0;
#include <iostream>
class Food{
};
class Nutritionist:public Food{
};
public:
float cal,fat;
void calorie(){
cin>>cal>>fat;
void dplan(){
if(cal<fat)
};
int main()
Patient p;
p.calorie();
p.dplan();
return 0;
#include <iostream>
using namespace std;
class Sam{
};
public:
int rows;
rows=y;
void display(){
for(int i=0;i<rows;i++){
for(int j=0;j<rows;j++){
cout<<"* ";
cout<<endl;
};
int main()
Robin obj;
int y;
cin>>y;
obj.read(y);
obj.display();
return 0;
}
#include <iostream>
class student{
public:
int roll,m1,m2;
void get(){
cin>>roll>>m1>>m2;
};
class sports{
public:
int sp;
void getsm(){
cin>>sp;
};
public:
void display(){
cout<<"Roll No:"<<roll<<endl;
cout<<"Total:"<<m1+m2+sp<<endl;
cout<<"Average:"<<(m1+m2+sp)/3<<endl;
}
};
int main()
statement obj;
obj.get();
obj.getsm();
obj.display();
return 0;
#include <iostream>
class Shape{
public:
int len,wid;
len=l;
wid=b;
};
public:
void output(){
cout<<len*wid<<endl;
};
public:
void output(){
//if((len*wid)%2==0)
cout<<0.5*len*wid<<endl;
//else
//cout<<len*wid/2+1<<endl;
};
int main()
int l,b;
cin>>l>>b;
Rectangle rect;
Triangle tri;
rect.input(l,b);
tri.input(l,b);
rect.output();
tri.output();
return 0;
}
#include <iostream>
class customer{
public:
int no;
string name;
void acceptc(){
cin>>name>>mobile>>no;
};
public:
int bal;
void acceptd(){
cin>>bal;
void dispd(){
cout<<"Customer Name:"<<name<<endl;
cout<<"Balance:"<<bal<<endl;
}
};
public:
void acceptb(){
cin>>loan_no>>amt;
void dispb(){
cout<<"Loan No:"<<loan_no<<endl;
cout<<"Loan Amount:"<<amt<<endl;
};
int main()
int n;
cin>>n;
borrow b1[n];
for(int i=0;i<n;i++){
b1[i].acceptc();
b1[i].acceptd();
b1[i].acceptb();
b1[i].dispd();
b1[i].dispb();
return 0;
}
#include <iostream>
class Receive{
public:
int r1,i1,r2,i2,r3,i3;
void getdata(){
cin>>r1>>i1>>r2>>i2;
};
public:
void add(){
r3=r1+r2;
i3=i1+i2;
};
public:
void output(){
cout<<r1<<"+"<<i1<<"i"<<endl;
cout<<r2<<"+"<<i2<<"i"<<endl;
cout<<r3<<"+"<<i3<<"i"<<endl;
}
};
int main()
Present calc;
calc.getdata();
calc.add();
calc.output();
return 0;
#include <iostream>
class Person{
};
};
public:
int n1,n2,basic,hra,da,pf;
string name1,role1,col,ifsc,name2,role2;
void getdetail(){
cin>>n1>>name1>>role1>>col>>ifsc>>n2>>name2>>role2;
}
void getEmployeeDetails(){
cin>>basic>>hra>>da>>pf;
void student_display(){
cout<<"Person number:"<<n1<<endl;
cout<<"Person name:"<<name1<<endl;
cout<<"Person Role:"<<role1<<endl;
cout<<"Student IFSC:"<<ifsc<<endl;
cout<<"Person number:"<<n2<<endl;
cout<<"Person name:"<<name2<<endl;
cout<<"Person Role:"<<role2<<endl;
void employee_display(){
cout<<"Employee HRA:"<<hra<<endl;
cout<<"Employee DA:"<<da<<endl;
cout<<"Employee PF:"<<pf<<endl;
};
int main()
Student e;
e.getdetail();
e.getEmployeeDetails();
e.student_display();
e.employee_display();
return 0;
cout<<"s.student_display();";