Swap the contents of two variables using a third variable.
Find the average of two numbers given by the user.
Receive 3 numbers and display them in ascending order from smallest to largest
Construct the class Complex that has floating point data members for storing real and imaginary parts and perform complex number subtraction using operator Overloading.
he class Complex has the following member functions:
Complex() - Null constructor invokes when an object is created
Complex(float, float) - Parameterized constructor to set the specified value of real and imaginary parts in object
Operator()- To subtract an object from another object
print() - Function to display complex number object
Test Case: 1
INPUT:
R1:15
I1: 2
R2: 5
I2: 10
OUTPUT:
A =15 + i2
B = 5 + i10
C = 10 + i(-8)
Design a C++ program having a base class Student with data member rollno and member functions getnum() to input rollno and putnum() to display rollno. The class Test is derived from class Student with data member marks and member functions getmarks() to input marks and putmarks() to display marks. The class Sports is also derived from class Student with data member score and member functions getscore() to input score and putscore() to display score. The class Result is inherited from two base classes, class Test and class Sports with data member total and a member function display() to display rollno, marks, score and the total (marks + score).
Testcase:
INPUT:
2
80
80
80
65
OUTPUT:
Roll no:2
Mark1:80
Mark2:80
Mark3:80
Sports score:65
Total:305 Ap 3 5
Write a program that reads all the match outcomes and summarizes the information of all the matches.
Points are given to the teams based on the outcome of the match.
A win earns a team 3 points. A draw earns 1. A loss earns 0.
The following information is expected:
MP: Matches Played
W: Matches Won
D: Matches Drawn (Tied)
L: Matches Lost
P: Points
The team information should be displayed in descending order of points.
Husna Dental is a personal dental clinic that recently operated on 1st January 2015. The payment for dentistry services at Husna Dental is different based on the type of treatment and patient status.
Patient Status
Restoration (1)
Extraction(2)
Scaling(3)
Children(C)
RM6.00
RM15.50
RM4.00
Adult(A)
RM7.50
RM18.00
RM5.00
Due to the opening ceremony, the discount of 20% will be given for children’s treatment and 15% discount for adult’s treatment.
Write a C++ program that performs the following.
· · · ·
Reads the patient's name, patient status, and type of treatment.
Displays the appropriate message when the user enters an invalid status. Calculates the payment before and after discount.
At the end of the program, displays receipt that contain patient’s name and her/his total payment after discount.
Write in 2 version of selction syntax using if..else and switch..case
Numbers in String - 2
Given a string, write a program to return the sum and average of the numbers that appear in the string, ignoring all other characters.
Input
The input will be a single line containing a string.
Output
The output should contain the sum and average of the numbers that appear in the string.
Note: Round the average value to two decimal places.
Explanation
For example, if the given string is "I am 25 years and 10 months old", the numbers are 25, 10. Your code should print the sum of the numbers(35) and the average of the numbers(17.5) in the new line.
Sample Input 1
I am 25 years and 10 months old
Sample Output 1
35
17.5
Sample Input 2
Tech Foundation 35567
Sample Output 2
35567
35567.0
Sample input 3
1time3 %times4
sample output 3
8
2.67
please provide correct output codeNumbers in String - 1
Given a string, write a program to return the sum and average of the digits of all numbers that appear in the string, ignoring all other characters.
Input
The input will be a single line containing a string.
Output
The output should contain the sum and average of the digits of all numbers that appear in the string.
Note: Round the average value to two decimal places.
Explanation
For example, if the given string is "I am 25 years and 10 months old", the digits of all numbers that appear in the string are 2, 5, 1, 0. Your code should print the sum of all digits(8) and the average of all digits(2.0) in the new line.
Sample Input 1
I am 25 years and 10 months old
Sample Output 1
8
2.0
Sample Input 2
Tech Foundation 35567
Sample Output 2
26
5.2
Sample Input 3
Anjali25 is python4 Expert
Sample Output 3
11
3.67
correct output is given the code
Write a program that reads in 20 numbers and calculates the average of the numbers which are smaller than 10.