Input a non-zero positive integer.
Using while loop, print out each digit of the inputted integer in separate lines, starting from its rightmost digit until the leftmost digit of the number.
Tip #1: Use % 10 to get the rightmost digit. For example, if you do 412 % 10, then the result would be the rightmost digit, which is 2.
Tip #2: On the other hand, use / 10 to remove the rightmost digit. For example, if you do 412 / 10, then the result would be 41.
Tip #3: You'd have to repeat Tip #1 and Tip #2 inside the while() loop for this problem while the inputted integer is not yet 0.
The output should be N lines containing the triangle pattern. Explanation For example,if the given number is 5,the pattern should be printed in 5 lines,as shown below
Write a program using one dimensional arrays that searches a number and display the number of times it occurs on the list of 12 input values
What are the input device
Given two strings write a program to merge the given two strings by adding character in alternating order starting with the first string if a string is longer than the other append the additional character onto the end of the merged string
input : a b c
p q r
Write a C++ program to solve the following problems (Red colour texts are to indicate user inputs that can be changed)
Out Put
Enter your Account Number: 2000342200267
Enter your Name: Abebe Kebede
Enter the amount: 1000
How long to keep it (number of month): 10
Dear Abebe Kebede
Acc: 2000342200267
After 10 Months you will get a total of 700 Birr Interest
Your Balance will be = 1700 Birr
Examine the incomplete program below. Write code that can be placed below the comment (// Write your code here) to complete the program. Use nested loops to calculate the sum and average of all scores stored in the 2-dimensional array: students so that when the program executes, the following output is displayed. Do not change any other part of the code.
OUTPUT:
Sum of all scores = 102
Average score = 17
CODE:
#include <iostream>
using namespace std;
int main()
{
const int NUM_OF_STUDENTS = 2;
const int NUM_OF_TESTS = 3;
int sum = 0, average = 0;
double students[NUM_OF_STUDENTS][NUM_OF_TESTS] =
{
{11, 12, 13},
{21, 22, 23}
};
// Write your code here:
cout << "Sum of all scores = " << sum << endl;
cout << "Average score = " << average << endl;
return 0;
}
Write a code that reads integers from the user until the user enters either 0 or 100. Then prints the sum of the numbers entered (excluding the 0 or 100).
What is the output of each of the following statements? Assume that
x = 5, y = 2, z = 10, and temp = 0
6. if (x + y > z)
x = y + z;
else
x = y - z;
cout<< x << " " << y << " " << z << endl;
What is the output of each of the following statements? Assume that
x = 5, y = 2, z = 10, and temp = 0
1. if (y >= x)
y = z;
cout<< x << " " << y << " " << z << endl;
2. if (y >= x)
{
y = z;
cout<< x << " " << y << " " << z << endl;
}
3. if (z < y)
temp = x;
x = z;
z = temp;
cout<< x << " " << y << " " << z << endl;
4. if (z > y)
{
temp = x;
x = z;
z = temp;
}
cout<< x << " " << y << " " << z << endl;
5. if (x >= 6)
cout<< x + y << endl;
cout<< x + y << endl;
6. if (x + y > z)
x = y + z;
else
x = y - z;
cout<< x << " " << y << " " << z << endl;