2.Construct a program in C++ to compute the sum of the digits of the numbers input from the user. Apply all the control structures. Display the number input by the user as well as the sum. Use for loop control structure.
Example display in Console Application
Input number: 93
———output——-
You input number 9 and 3.
The sum of the digits 9 and 3 is 12.
1. Create a C++ program that asks the user to input full name 5times using for, do while and while loop. Then,display.
1.a. For loop
1.b. While loop
1.c Do while loop
Example display in console application
—-This program can accept 5 full names from the user——
Please enter five full names :
Carlo Adam
Justin Doe
Liam Baird
Mike Tan
John Davis
//Expected output:
You entered the following names:
Carlo Adam
Justin Doe
Liam Baird
Mike Tan
John Davis
Congratulations!
Create an enumeration named Month that holds values for the months of the year, starting with January equal to 1. Write a program that prompts the user for a month integer. Convert the user’s entry to a Month value, and display it.
Use three functionsto perform the following tasks:
modify should modifythe values of fnum and snum as stated.
-Modify the contents by multiplying the original values by 10. The function
-Display the new value to the user. The function displayshould print to the
local variables fnumand snum.
-Accept two integers from user. A functioncaptureshould do this using its
user the new values of fnum and snum variables.
Use a single-subscripted array to solve the following problem. A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a salesperson who grosses $3000 in sales in a week receives $200 plus 9 percent of $3000, or a total of $470. Write a C program (using an array of counters) that determines how many of the salespeople earned salaries in each of the following ranges (assume that each salesperson’s salary is truncated to an integer amount):
a) $200–299
b) $300–399
c) $400–499
d) $500–599
e) $600–699
f) $700–799
g) $800–899
h) $900–999
i) $1000 and over
Make a class named Fruit with a data member to calculate the number of fruits in a basket. Create two other class named Apples and Mangoes to calculate the number of apples and mangoes in the basket. Print the number of fruits of each type and the total number of fruits in the basket.
Write a program to print the following, Given a word W and pattern P, you need to check whether the pattern matches the given word.The word will only contain letters(can be Uppercase and Lowercase). The pattern can contain letters, ? and *.
? : Can be matched with any single letter.
* : Can be matched with any sequence of letters (including an empty sequence).
If the pattern matches with the given word, print True else False.
Sample Input1
3
Hello *l?
Hell He?ll
Hell ?*
Sample Output1
True
False
True
Sample Input1
3
Hello Hell*
Hell He*ll
Hell hell*
Sample Output1
True
True
False
Write a program to print the following output.
Input
The first line contains a string.
The second line contains some space-separated strings.
Output
The output should be a single integer.
Explanation
scramble word = "tacren"
guessed words = ["trance", "recant"]
Since "trance" and "recant" both have length 6 then you score 54 pts each.
So the output is 108.
Sample Input1
tacren
trance recant
Sample Output1
108
Sample Input2
rceast
cat create sat
Sample Output2
2
Write a python program to print the following output.
Input
The first line of input contains a single line positive integer N.
The second line of input contains a space-separated integers denoting the cost of the item.
Output
The output is a single line integer.
Explanation
For example, Given N = 2 and cost = 10 200
Ram has to pay for both the items, he won't get anything for free.
So the output is 210.
Sample Input1
2
10 200
Sample Output1
210
Sample Input2
4
1 1 2 2
Sample Output2
4
Python Problem Solving
You're given a positive integer: Perform the sequence of operations as per below guidelines until the value reaches 1:
If N is even --> N / 2
If N is odd --> N * 3 + 1
Print the total number of steps it took to reach 1.
Input
The first line of input contains an integer.
Output
The output should be a single integer denoting the total number of steps.
Explanation
For Example, using N = 10 as the input, with 6 steps.
10 is even - 10/2 = 5
5 is odd - 5 * 3 + 1 = 16
16 is even - 16 / 2 = 8
8 is even - 8 /2 = 4
4 is even - 4/2 = 2
2 is even - 2/2 = 1 --> Reached 1.
So the output should be 6.
Sample Input1
10
Sample Output1
6
Sample Input2
345
Sample Output2
125