How to pass a parameter to a function that is called on an event?

C++ programming questions?

  • 1)Write a program that prompts the user to enter an integer (0-999), and then outputs each digit separately. The user should be able to enter integers and see the digits as many times as they want, a negative integer will signal the program to quit. An input value greater than 999 should trigger the response "Invalid input: try again". For this program, you should have at least one procedure, called find_digits: Since up to three separate items need to be extracted from the input, and since a function can only return a single value through a return statement, you will instead have to use pass-by-reference parameters to "pass back" the digits. So your procedure should have a return type of void and take 4 parameters: the number itself (should be a value parameter), and a reference parameter for each digit of the number. 2)Write a program that allows a user to randomly draw two cards and see if they win a prize. Each card's value (2-10, Jack, Queen, King, and Ace) and suit (hearts, diamonds, spades, and clubs) will be randomly chosen. You will need to use integer values as codes for those things that are not integers (Jack, Queen, hearts, diamonds, etc.). This will allow you to use the rand() function which only generates integers. However, when printing the two cards, you should translate the integers into what they are representing. For example, you should output, "You drew a 3 of Hearts.", or "You drew a Jack of spades." Do not output, "You drew a 12 of suit type 2". Lastly, output whether they win. A pair (two of the same value (suit doesn't matter)) wins a large prize. Drawing a Jack (of any suit) wins a small prize. You should use the library's rand() function from the previous experience to generate your card value (2-10, Jack, Queen, King, Ace) and your suit. You must also write the following functions: translate_card_num, translate_card_type and print_winnings. You may write additional functions if you wish. 3)Write a predicate function that tests whether a year is a leap year bool leap_year( int year ) A leap year is: a year with 366 days. Leap years are necessary to keep the calendar synchronized with the sun because the earth revolves around the sun once every 365.25 days. Actually, that figure is not entirely precise, and for all dates after 1582 the Gregorian correction applies. Leap years follow some basic rules: Usually years that are divisible by 4 are leap years, for example 1996. However, years that are divisible by 100 (for example, 1900) are not leap years. But years that are divisible by 400 are leap years (for example, 2000). For more of a challenge, write this function as a single return statement (no if statement(s)).

  • Answer:

    Did you attempt to do any of these programs? I see no incentive for me or anyone else to do them for you, just so you can take credit and receive a grade for it.

~V3N0M~ at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Not here to do your homework. Attempt the questions, then if you have any problems, post the code so we can help you.

for the first one int num; hundreds=(num/100)%10; tens=(num/10)%10; ones=num%10; you can do the rest for leap year bool isLeap(int year){ return year%400==0 ||( year %100 && year %4==0); }

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.