Program Objective: • Develop input validation loop • Develop sentinel-controlled loop • Program separate functions for different sub-problems Program name. Named students score percentage (batch mode) Problem Statement. Write c program that inputs 2 numbers (n and r). Both inputs should be validated using a function int validateInput();, where valid values are positive integers. The function keeps on scanning a single integer value until a valid value is available. The function should then return this valid value. (Hint: use input-validation do-while loop format for this and develop the input validation function as done in online lab 2.) After validating the inputs, the program shows the following input menu to the user. (Hint: you may use a separate void function for displaying these instructions only.) Press 1 for multiplying numbers. Press 2 for finding nCr. Press 3 for finding nPr. Press -1 for Exit. The program should then perform the appropriate task according to the choice input by the user. Ignore validation of the choice input. (Hint: Use a sentinel-controlled loop format for this, where sentinel value is -1.) (Hint: Formulae for computing combination and permutation: • Comb = n!/(r!*(n-r)!) • Perm = n!/((n-r)!) Use a counter-controlled loop for computing factorial of n (n!). This is a running product pattern very similar to running sum, as discussed in lecture 1 on while loop.)
Answers
Answered by
3
Answer:
Named Students Score Percentage Problem Statement. Write A Program That Inputs 2 Numbers (n And R)
Similar questions