# C++ Solved programs, problems/Examples with solutions

Subscribe
Notify of

Inline Feedbacks

You are tasked by Skontiri Delivery Company, to develop a system to calculate the delivery cost for their clients. Clients are charged per pounds in weight based on the delivery area code. A Provincial delivery code is 1, a National delivery code is 2 and an International delivery code is 3. The fee for the delivery is as follows: For each delivery, enter the delivery number (use as sentinel), weight and specify if the delivery is insured or not. Before you calculate the Price confirm if a valid area code is entered. Price is calculated per pounds based on the… Read more »

Hi please i am help me soultion plz

#include <iostream> #include <string> double calculatePrice(int areaCode, double weight) {     double feePerPound;     switch (areaCode) {         case 1:             feePerPound = 1.5;             break;         case 2:             feePerPound = 2.5;             break;         case 3:             feePerPound = 4.0;             break;         default:             std::cout << “Invalid area code” << std::endl;             return 0.0;     }     return feePerPound * weight; } double calculateTax(double price) {     const double taxRate = 0.1;     return price * taxRate; } double calculateInsurance(double price, bool insured) {     const double insuranceRate = 0.05;     if (insured) {         return price * insuranceRate;     }     return 0.0; } int main() {     std::string areaName;     int deliveryNumber, areaCode;     double weight, price, tax, insurance, total, grandTotal = 0.0;… Read more »

cout <<“Machine is working: “<< machineisworking;

#include <iostream>
#include <string>
#include<math.h>
using namespace std;
int main()
{
int price=10,total,tax=1.088,weight,area_code,deliveryno;
cout<<“\n DELIVERY CALCULATOR:”;
cout<<“\n enter the delivery number”;
cin>>deliveryno;
cout<<“\n enter the weight of the package”;
cin>>weight;
cout<<“\n Enter the area code from below:\n Provincial delivery code is 1\n a National delivery code is 2\n and an International delivery code is 3.\n”;
cin>>area_code;
switch(area_code)
{
case 1:
total=weight*price*tax*1;
break;
case 2:
total=weight*price*tax*2;
break;
case 3:
total=weight*price*tax*3;
break;

}
cout<<“\n the delivery fee is:”<<total;
return 0;
}

#include <iostream>
//#include <string>
//#include<math.h>
using namespace std;
int main()
{
int price=10;
int tax=2;
int total,weight,area_code,deliveryno;
cout<<DELIVERY CALCULATOR:“;
cout<< enter the delivery number<<endl;
cin>>deliveryno;
cout<<enter the weight of the package<<endl;
cin>>weight;
cout<< Enter the area code from below: Provincial delivery code is 1 a National delivery code is 2 and an International delivery code is 3.<<endl;
cin>>area_code;
switch(area_code)
{
case 1:
total=weight*price*tax*deliveryno;
break;
case 2:
total=weight*price*tax*deliveryno;
break;
case 3:
total=weight*price*tax*deliveryno;
break;

}
cout<< the delivery fee is:<<total;
return 0;
}

sorry

Write a program that prompts the user to enter two integers.

The program outputs how many numbers are multiples of 3 and how many numbers are multiples of 5 between the two integers (inclusive)

#include
using namespace std;
int main()
{
int a,b,i,count1=0,count2=0;

cout< first integer): “<>a>>b;

for(i=a;i<=b;i++){
if(i%3==0){
++count1;
}
}

for(i=a;i<=b;i++){
if(i%5==0){
++count2;
}
}

cout<<"No. of multiples of 3: "<<count1<<endl;
cout<<"No. of multiples of 5: "<<count2;

return 0;

}

These programs are wonderful! But, the most important thing is missing is the comments! I am not saying that there should be comment for every line of code but where ever it need so. I am sure without comments, it’s not useful for students nor for anyone novice to programming! That’s why this site has less viewers.
Still, it is something that can be revised anytime.

marks in maths >= 70
marks in physics >= 65
marks in chemistry >= 60
Total marks in all three subjects >= 180

Make a function bool Is_Digit (char n) which returns true,..if the character is between character 0 to 9 else, it
returns false using inline function. plz help

Write a program that creates and then reads a matrix of 4 rows and 4 columns of type int. while reading; the program should not accept values greater than 100. For any entered value greater than 100, the program should ask for input repeatedly. After reading all numbers, the system should find the largest number in the matrix and its location or index values. The program should print the largest number and its location (row and column).

write a programme which stores different tax record of a company

There is a garage where the access road can accommodate any number of trucks at
one time. The garage is build such a way that only the last truck entered can be
moved out. Each of the trucks is identified by a positive integer (a truck_id).
Write a program to handle truck moves, allowing for the following commands:
a) On_road (truck_id) b) Enter_garage (truck_ id)
c) Exit_garage (truck_id) d) Show_trucks (garage )

Good day everyone, please i would like to know how to write a nested if program following a step by step process;
payment of fees
online registration
identification card
an allocated hall of residence
Please i will need all the help i can get, i am a computer science student and i am having little problems with this… please can i get the information sent to my provided gmail account. THANK YOU SO MUCH FOR YOUR FURTHER ASSISTANCE IT NEEDS TO BE SUBMITTED IN LESS THAN 12 HOURS ALL THE HELP I WILL GET WOULD BE NEEDED,

You are given a sequence a1, a2, …, aN. Find the smallest possible value of ai + aj, where 1 ≤ i < jN.
Input
The first line of each description consists of a single integer N.
The second line of each description contains N space separated integers – a1, a2, …, aN respectively.
Output
A single line containing a single integer (the smallest possible sum).
Sample Input1:
Sample Input2:
4
5 1 3 4
10
9 2 7 4 5 6 3 8 1 10
Sample Output2:
Sample Output2:
4
3

Write a C++ program to calculate the tuition fee for a student at a University. The program should prompt for and accept the idnumber and the total number of credits for which he/she has enrolled. The bill outputted should contain the idnumber and tuition fee. Calculate the tuition fee as follows: • Total credits of 15 or more indicates that the student is full-time. Full-time students pay a flat rate of \$35,000 for tuition. • Total credits of less than 15 indicate that the student is part-time. Part-time students pay \$850 per credit for tuition. After printing the tuition fee,… Read more »

#include<iostream> using namespace std; class Student{ public: string regNo; int noOfcredits; double tBill; string status1 = “Full-time”; string status2 = “Part-time”; string answer; }; isBool(string answer){ if(answer == “yes”){ return true; }else if(answer == “no”){ return false; } } int main() { Student stud1,stud2; stud1.regNo; cout << “Enter registration number: ” ; getline(cin, stud1.regNo); stud1.noOfcredits; cout << “Enter number of credits: ” ; cin >> stud1.noOfcredits; isBool(stud1.answer); stud1.tBill; if(stud1.noOfcredits > 15){ cout << “Status: “<< stud1.status1 ; cout << “\nTution fee: \$35,000 “; cout << “\nCalculate tution fee for another student? “; cin >> stud1.answer; }else{ cout << “Status: “<< stud1.status2… Read more »

Write a program to display only months, but with a forward/backward button to move bw the months from January to December

Welcome   A recently launched attraction at the “Events Square” entertainment fair is the “Carnival of Terror” which is an interactive fun zone featuring scary, horror and Halloween stories.   The Entry tickets for the show is to be printed with a Welcome message along with an additional message for Children stating they should be accompanied by an adult. Given the age of the person visiting the scary house, the ticket should carry the additional message only for Children whose age is less than 15 years. The show organizers wanted your help to accomplish this task. Write a program that… Read more »

#include<iostream>

using namespace std;
class Child{
public:
string name;
int age;
};

int main()
{
Child child1;
cout << “Enter child’s first name: “;
cin >> child1.name;
cout << “Enter age: “;
cin >> child1.age;
if(child1.age > 15){
cout << child1.name << ” welcome to Carnival of Terror..”<< endl;
}else{
cout << child1.name << ” welcome to Carnival of Terror..”<< endl;
cout << “Please note that you should be accompanied by an adult..”<< endl;
}
return 0;
}

galat program hai

. include new functions of
-print a single node
-print entire list
search a node by, name, id, cnic, dob (function overload…one function per filter)
-insert at tail

The management of Lifetime Company Limited decided to pay a bonus of 4.3% of total sales to every salesperson of the company who made total sales of GHS 5000 or more in six (6) months. Write a C++ program to accept the monthly sales of each salesperson and display whether the person deserve a bonus or not.

hello programmer

Find Second Maximum Number(using operators &&, >, <)
Write a program which takes 3 input integers and tell the 2nd maximum. Sample Input :
90 5 60
Sample Output

In this program the user has to insert two integer numbers: number1 which must be between 1 and 50 inclusive (i.e. 1<= number1 <=50) and number2 which must be between 51 and 100 inclusive (i.e. 51 <= number2 <= 100). A wrong inserted value for any number causes the output message “Invalid” to be displayed on the console and the program returns. When valid numbers are entred, they are used to in a loop that applies the following equation in each iteration: k = i * i + 2 * j. In this loop, “i” represnts a series of consecutive ascending even numbers starting with… Read more »

can you provide some more programs of oop for better pratice and for concept clarification ?

This website is very helpful . I’m in love with it .

Supermarket is a retail facility with wide range of products under one roof, including fullgroceries and general merchandise. They satisfy the customers in all their routine shopping needs in one trip. Arun owns a supermarket in Chennai and he wanted to create a software that contains the purchase details of all the customers made on that day and at the end of the day, he wants to calculate the total amount received and the total number of items purchased by all the customers in a database. Help him to do this by writing a C++ program. Strictly adhere to the Object Oriented Specifications… Read more »

write c++ program to add two integer vectors together and store them in a third vector. the first two vectors should accepts user input for five elements each.

The representation of a complex number as a sum of a real and imaginary number, z = x + i y, is called its Cartesian representation. We can therefore express any complex number z = x + i y into , this representation is known polar representation of any complex number z. where                                                                                                                      and You need to create a class having name, Polar Representation with data members, magnitude and angle. Make sure you provide a default constructor too. Overload following operators of the class; 1.     + operator (to add two objects of class) 2.     – operator (to subtract two objects of class) 3.     * operator (to multiply… Read more »

Last edited 2 years ago by dina ashraf

. Write a “Garage” class that has a “Car” that is having troubles with its “Motor”. Use a function-level try block in the “Garage” class constructor to catch an exception (thrown from the “Motor” class) when its “Car” object is initialized. Throw a different exception from the body of the “Garage” constructor s handler and catch it in main( ).
﻿

Write a program that asks the user to enter the number of courses he/she is taking and then enter the course code and its number of credits. The program should sum the total number of credits and display it.

Create publisher class that represents a book publisher, publisher has two properties/attributes name and a code which should be a non-negative integer. Class must have a constructor that should take parameters to set the both properties, get functions for both attributes, a set method to change name. and a print function to print/display the publisher. now create a main function make and object of publisher, print the publisher then change the publisher code and again print the publisher. your program should run like this
the old publisher
the new publisher

Define a class named ‘Train’ representing following members:
Data members :- – Train Number
– Train Name
– Source
– Destination
– Journey Date
– Capacity
Member functions:
– Initialise members
– Input Train data
– Display data
Write a C++ program to test the train class.

Develop a geometry calculator that will do the following things:
1. It should give the user many options to choose between (user should right 1 if
he/she wants to calculate something related to circle, 2 for rectangle and so on).
Like
1. Circle
1. Area
2. Circumference
2. Rectangle
1. area
3. Triangle
1. Area
2. base
4. Parallelogram
1. Area
5. Trapezoid
1. Area

2. Each of these operations must be handled by a function
3. You should use call by value, call by reference with pointers in any of these
functions

Your task is to create a program that examines the distribution grades on an exam. Ask the user to input how many students does he have followed by the grades of those students. Then, group the grades depending on the range and then display the summary in a bar graph format. The ranges are as follows: 0 – 9, 10 – 19, 20 – 29, 30 – 39, 40 – 49, 50 – 59, 60 – 69, 70 – 79, 80 – 89, 90 – 99, and 100.

A company has three types of employee: 1. Managers: receive a fixed monthly salary 2. Commission Workers: receive \$1000 plus 5% of their gross monthly sales 3. Piece Workers: receive a fixed amount of money per item for each of the items they produce; each pieceworker in this company works on only one type of item. Write a program to compute the monthly pay for each employee. P.S: You do not know the number of employees in advance. Each type of employee has its own pay code:  Managers have code 1  Commission Workers have code 2  Pieceworkers… Read more »

write a program
1) Declare all variables and constants paying attention to the types
2) Calculate the area of ​​the circle given the radius
3) Divide the area of ​​the circle by the number of segments, but only if this number is different from zero
4) Print all partial results

Overload the ‘subscript’ operator for the class ‘String’ so that it takes a
character as a parameter and returns the position of its first occurrence.
The output of the following code should be two.
String s1(“abcd”);
cout<<s1[‘c’]<<endl;
Also, overload ‘+’ operator to merge two strings.
1. Find
2. Merge
3. Exit

plz help me

s]

Write a program to process the quote Four Score and Seven Years Ago. Copy the quotation into a string. Create three character arrays – one for vowels, one for consonants and one for reverse order. The program will copy the vowels into the vowels array, the consonants into the consonants array and the reverse order quote into the reverse array. For example, if the string were “hello world”: • The vowels array would equal ‘e’, ‘o’, ‘o’ • The consonants array would equal ‘h’, ‘l’, ‘l’, ‘w’, ‘r’, ‘l’, ‘d’ • The reverse array would equal ‘d’, ‘l’, ‘r’, ‘o’,… Read more »

1) Prompts the user to enter from the keyboard car price and profit percentage. (Both are float). 2) Calculates the total price using car price and profit percentage. For example, if the car price is 100 BD and profit percentage is 25%, then the total price is 125 BD. 3) Display the value of car price, profit percentage, total price. Each in separate line formatted in two decimal places. Sample Input/output (Input in red color)

whats my problem

#include<iostream>
using namespace std ;
int main()
{
return 0 :
}

help
problem?

Write a program to display your name 500 times

Write a program to accept any number and check whether the number is even or odd

Using switch case statement accept any two numbers and display sum, product or difference according to the user’s choice. An appropriate message should be displayed for the wrong choice
﻿

Write a program to accept any positive integer and display its square. i.e. if the input is 5 then the output should be 25. Program will exit only if user enters less than or equals to 0
﻿

#include<iostream>
using namespace std;
int main()
{
/*Write a program to accept any positive integer and display its square.
i.e. if the input is 5 then the output should be 25.
Program will exit only if user enters less than or equals to 0 */

int num;
cout<< “Enter any number :”;
cin>>num;
if( num<0)

exit(0);

else

cout<<num<< ” it’s square is “<<num*num<<endl;

return 0;
}

Write a program to accept any number and display the sum of its factors.*
﻿

The programme below in C++ is given to you. Complete the  Binnary Search function so as to work properly with a head and tail pointer and return whether value x is included in the table or not. Assume that the table already has all its elements in ascending order. // Example program #include #include using namespace std; void filltable(int *p){   for (int i=0; i<5; i++){   cout <> *p;   p++;   } } void printtable(int *pr){   for (int i=0; i<5; i++){   cout << *pr <<"  ";   pr++;   } } void findx(int *p, int x){… Read more »

Write a c++ program to perform following operations:
Create a class with following Data Members and Member Functions:
• Data Members : JavaMarks and CPPMarks
• Member Functions:
◦ Constructor() – Create a constructor to initalize the data
members
◦ Overload the binary + operator using Friend Function
◦ Display() – Display the data
◦ Call the Destructor at the end of the code

Input:

• A string (X).
• A letter (L1).
• A letter (L2).

Output:
–       The same string (X) , but modified as the following:
o  Find some word that
end with the letter (L2).
o  Copy the founded word to the last of the array but in reverse manner.
Example:
L1 = ‘S’
L2 = ‘L’

w
e

h
i
s

SS
C
H
O
O
LL

y
e
s

c
o
m
e
‘\0’

x[]= we his school yes come loohcs ‘\0’

how can i solve it

write a C++ program to find number of similar words between 5 text files and 1 source file one by one, and common phrases among the these files

i like that you have variety of questions.

hi I want code of that program

s= y/(x+1)! +y/(x+2)! +y/(x+3)! +…. y/(x+n)!