The function below calculates and returns the sum of integers between 1 and n (inclusive) where n is an integer accepted by the function i.e.
If n = 3;
then the function returns 6 (1+2+3). int sum(int n) { int sum = 0;
while (n > 0) { sum = sum + n; --n; } return sum;
}
Rewrite the body of the sum function using a single do-while loop instead of a while-loop
Write a C++ program that accepts an input value in Tambala from the user and
then the program should convert the value to equivalent value in Kwacha and
Tambala.
(For example, if the user enters 112 as input value, the program should display:
1 Kwacha and 12 tambala
A number is called a happy number, if you start with the given number and arrive at 1 by repeating the following process (as illustrated in the below example): (a) compute the sum of the squares of given number digits (b) if the resultant value is 1, then the number is happy number, else execute point (a) for the newly produced number. Note that if a number is not a happy number, there will be an endless loop to this execution. Goal: In this question, you are required to write a recursive function that checks whether the number entered by the user is a happy number or not for 10 cycles/iterations only. The output shown in blue colour should be shown by the function and text in yellow colour should be displayed by the main function.
Create a Python function that takes a list and returns a new list with unique elements of the first list.
Sample List : [1,2,3,3,3,3,4,5]
Unique List : [1, 2, 3, 4, 5]
I need the code to have an output stated above.
Create a Python function that takes a number as a parameter and check the number is
PRIME or NOT.
I need the code to have an output stated above.
Please write class for hash table using chaining and it must contain the following functions:1. Create a reflection of the given image.
2. Submit the code
images name(mt-rainier.jpg)
Create a Python function that takes a list of n integers and returns the largest number among the n integers.
I need the code to have an output stated above.
Elle Joy Vasquez
Preliminary Test 04
Create a Python function that takes a list of n integers and returns the largest number among the n integers.
Elle Joy Vasquez
Preliminary Test 03
Create a Python function that takes a list and returns a new list with unique elements of the first list.
Sample List: [1,2,3,3,3,3,4,5]
Unique List: [1, 2, 3, 4, 5]