1. Write a function that would take a character and a number as input and it would display the character and repeat it a

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

1. Write a function that would take a character and a number as input and it would display the character and repeat it a

Post by answerhappygod »

1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 1
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 1 (20.81 KiB) Viewed 66 times
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 2
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 2 (20.81 KiB) Viewed 66 times
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 3
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 3 (20.81 KiB) Viewed 66 times
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 4
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 4 (25.48 KiB) Viewed 66 times
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 5
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 5 (24.69 KiB) Viewed 66 times
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 6
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 6 (18.83 KiB) Viewed 66 times
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 7
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 7 (29.83 KiB) Viewed 66 times
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 8
1 Write A Function That Would Take A Character And A Number As Input And It Would Display The Character And Repeat It A 8 (22.27 KiB) Viewed 66 times
1. Write a function that would take a character and a number as input and it would display the character and repeat it as many times as the given number. Then in the main function, askuser for a character and a number and call the function to repeat it as many times as user requested it. incluso lontrams using namespace std; vold Repeat character(char character, int count to Repeat for tinto count to Repeat! ++ cout ce character cout<<endly int main() hà Int count cout<" Come character, cin >> che cout << "how many times do you want to repaita cin >> count Repeat character (ch, count) return

2. Run the following function and display the output. Provide explanation on how the application runs to justify the final output vold Run tortint 58++ tor unt judi jous, 31 GO Cout1 cout << cout Condi General Idea: For each value of ij starts from i and goes backward until 5. Then if value of jis divisible by 3, display I otherwise display value of j, Iterations: For i = 5 → goes from 5 to 5 and we will have this on the first line 5 For i = 6 → i goes from 6 to 5 and we will have this on the second line 15 • For i =7 →goes from 7 to 5 and we will have this on the third line → 715 - Final output: 5 15

3. Write an application that prompts user to enter 2 real numbers and an operator. It will then display the result of the operation. Your application should support addition, multiplication, division, and modulus (remainder) operations. tinclude <iostream> ng namespace std; int main() double num, num 2: chat op cout << "please enter the rat number: ". cin >> num: cout << "poate unter the operator: " ein >> Op cout<<"lote enter the second numbet cin >> num2 cout << numl << " " << op <<<< num2 <<" tehop case; cout << num+ num2; break; casecout << numi num: break case; cout << numl num2 break: cano 1 (num2=0) cout<<"EEEE, divison by 01 cout << numinum2: break caso cout <(int) num (int) num breaks 1 return 0 1

4. Write a function called IsFun that would determine (return true/false) if a given number is divisible by product of its digits. For example 432 is divisible by 24 (4*3*2) therefore this function should return true for 432 bool aun (int number int digits Product I, dicit, original Numbers original Number - number; while number 0) while digit number 103 digits Product digit: numbe number / 103 if (digits Product 03 return false; return original Number digits product 0;

6. A) Write a function sumEven that would accept an integer num and return the sum of all even numbers from 2 to num. int sumEven (int num) int sum = 0; for (int i=2; i<num; i+2) sum + i; return sum; B) Write a program that uses function sumEven from A (only write the main function) and take a number n from the user and then display the sumEvens for 2 to n leg. sumEven(2) sumEven(n)) on each line. int main int ni cout << "Please enter a number: "; cin >>n; for (int i=2; i<=n; i++) cout << "sumEven (" < i << ") << sumEven (i) << endl; return 03

7. A) Write a function Reverse that would take an integer and return the number in reverse order (0.8. 1426 > 6241) int Reverso (int num) int rev - 0, digiti while 0) digit = num10: rev-rev 10+ digits numnum / 101 return rev: B) Write a program that uses the function from part A (only write the main function) and display the difference between each number and its reverse between 300 and 400. int main() Int revi for (int i=300; i<400; i++) rev Reverse (1) cout << i << << rev << " " << 1 - rev << endl; return 02
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply