hands on

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.5 kB
12
Indexable
Never
HANDS-ON 1 (USING WHILE LOOP)
Write a program that asks for a number (n) and display the pattern below using WHILE LOOP.

Example:

if n=5

Display:

    55555
    44444
    33333
    22222
    11111




HANDS-ON 2: FUNCTION WITH NO RETURN VALUE
Using a function with no return value, write a program that accepts 2 numbers and display the:

        -sum (function getSum)

        -product (function getProduct)

        -difference (function getDiff)

        -quotient  (function getQuotient)




HANDS-ON 3: FUNCTION WITH RETURN VALUE
Using a function with  return value, write a program that accepts 2 numbers and display the:

        -sum (function getSum)

        -product (function getProduct)

        -difference (function getDiff)

        -quotient  (function getQuotient)





HANDS-ON 4: FUNCTION WITH PASS BY VALUE
Using a function with  PASS BY VALUE, write a program that accepts 2 numbers and display the:

        -sum (function getSum)

        -product (function getProduct)

        -difference (function getDiff)

        -quotient  (function getQuotient)






QUIZ 4 (PROGRAMMING)
PROBLEM:
Write a program that asks for an integer value for n from the user and display the sum of the squares of the numbers from 1 to n.

    Example: if n= 3 then compute sqr(1) +sqr2 +sqr3 which equal to 14; display 14.

Read the value of n in the main program, the use a function SUMSQUARE(n) to compute for the sum of the squares. Display the sum in the main program.






QUIZ 5 (PROGRAMMING)
PROBLEM:
Write a program that asks for 2  integer values (n and m) from the user and display the sum of the numbers from n to m.

    Example: if n= 3  and m=5 then compute 3 + 4 + 5 which equal to 12; display 12.

Read the value for n and m in the main program, the use a function SUM(n,m) to compute for the sum of numbers from n to m. Display the sum in the main program.






PROJECT
Write a program that accepts a 5 digit integer number in the main program and produces output DEPENDING ON THE CHOICE OF THE USER through the functions described below. Supply appropriate parameters. 

a. Display_with_Spaces(...)

   Given the value of num in the main, this function should display num with spaces in between. This function should not return any result to the main program.

b. Reverse_Num(..)

   Given the value of num, this function should return the reversed form of num to the main program. The reverse form must be displayed in the main program.

c. Sum_odd_Position(...)

    Given the value of num, this function should return the sum of odd-positioned digits to the main program. The sum of odd-position digits must be displayed in the main program.

d.  Sum_Even_Position(...)

    Given the value of num, this function should return the sum of even-positioned digits to the main program. The sum of even-position digits must be displayed in the main program.

e. Exchanged(...)

    Given the value of num, this function should return the number with the first and last digits exchanged to the main program.  The changed number must be displayed in the main program.


TEST DATA:
Enter number: 231085

Display_with_spaces: 2 3 1 0 8 5

Reversed Num: 580132

Sum_of_Odd_position: 8

Exchange: 531082


NOTE: Implement the program in which user could choose which function would he/she wants to execute.