Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
In C++
Write a recursive function called PrintNumPattern() to output the following number pattern.
Given a positive integer as input (Ex: 12), subtract another positive integer (Ex: 3) continually until 0 or a negative value is reached, and then continually add the second integer until the first integer is again reached. For this lab, do not end output with a newline.
Ex. If the input is:
12
3
the output is:
12 9 6 3 0 3 6 9 12
#include <iostream>
using namespace std;
// TODO: Write recursive PrintNumPattern() function
int main(int argc, char* argv[]) {
int num1;
int num2;
cin >> num1;
cin >> num2;
PrintNumPattern(num1, num2);
return 0;
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- In C++arrow_forwardIn c++arrow_forwardcode in python program please Write a function that takes one integer parameter, makes sure it is an integer, prints sum of every two digits and return the sum of digits from the number entered by the user up to 1, using recursion.Sample input: 4 Sample output: 4+3 = 77+2 = 99+1 = 10arrow_forward
- Asaparrow_forwardIn pythonarrow_forwardpython with a function “harmonic(n)” that computes the n-th harmonic number, write a function “harmonic_all(n)” that returns the number of values generated until all values are obtained as a function of the range of possible values n, then write a function “harmonic_sim(n)” that repeats “harmonic_all(n)” a total of n_sim = 100 times. function harmonic(n) is written: def harmonic(n) : harmonic = 1.00 for i in range(2, n + 1) : harmonic += 1 / i return round(harmonic,2) please help with harmonic_all and harmonic_simarrow_forward
- Write a C++ program to read in 10 prices (function getprices). Then write function caldiscount to do a 10% discount of all the prices in the array. Next write calaverage to calculate the average. And finally write printarray to print all the prices in the array it's urgent give me proper codearrow_forwardWrite a c++ program that includes two functions for sorting integers. your program must acts as following: Ask the user to enter 5 numbers and then by calling Asc() and Dsc() functions sort these 5 numbers in ascending and descending orders. Sample output: How many integers you wants to sort? 5 Please enter 5 integers: 5 8 -1 0 2 the ascending order of your list is: -1 0 2 5 8 The Descending order of your list is: 8 5 2 0 -1 Note: to do the above question do not use the array , vector or class. Use swaparrow_forwardIn C programming, if the return type of a function is Void how can you implement assert statements? For example, Void ceasar(int n, char*x); //if char = c and n = 3 output == f how do i use assert statements as this does not work assert (caesar(3,c)==f);arrow_forward
- This is in C++. Write a function that, given a string, index, and character, returns the index of the first occurrence of the character starting the search at the index. If not found, return -1. If the inputs are "Hello-friends", 3, and 'e', the function returns 9 (indexing the 'e' in friends). Use a for loop along with a boolean variables to indicate the character was found, which should end the for loop immediately. main.cpp #include <iostream>#include <string>using namespace std; // Type your code hereint main() {string inputString;int startIndex;char searchChar;cin >> inputString;cin >> startIndex;cin >> searchChar;cout << FindNextCharInString(inputString, startIndex, searchChar) << endl; return 0;} Thank youarrow_forwardSolve it as soon as possible using C programarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education