The function Power, which raises the integer number x to the power n, can be defined recursively as follows: Power(x, n) = 1 for n = 0 Power(x, n) = x * Power(x, n-1) for n > 0 (i) Using the above definition write the recursive function Power(x, n) in C. (ii) Rewrite the recursive function Power(x, n) in an iterative form. (iii) Write the main function and test the above written functions. Note: You can write one program and test the functions or you may write two separate programs for each part (i) and (ii).
pager
imagine a pager with only one button for the letter "A" you press the button one time for "B"ou press it two times for "E" you press it five times ,for "G" its pressed seven times
explanation :
for example if the given strings abcde , then
the total number of times the button pressed 1+2+4+5
so the output is 12
input: abde
output: 12
intput:xyz
output:75
Prefix Suffix
Write a program to check the overlapping of one string's suffix with the prefix of another string.Input
The first line of the input will contain a string A.
The second line of the input will contain a string B.Output
The output should contain overlapping word if present else print "No overlapping".Explanation
For example, if the given two strings, A and B, are "ramisgood" "goodforall"
The output should be "good" as good overlaps as a suffix of the first string and prefix of next.
input:
ramisgood
godforall
output:
good
input-2:
finally
restforall
Write a program that dynamically allocates an array large enough to hold a user-defined number of test
scores. Once all the scores are entered, the array should be passed to a function that sorts them in
ascending order. Another function should be called that calculates the average score. The program
should display the sorted list of scores and averages with appropriate headings. Use pointer notation
rather than array notation whenever possible.
Input Validation: Do not accept negative numbers for test scores.
Example
Enter the number of test scores: 4
Enter each test score:
Test#1: 34
Test #2: 73
Test #3: 22
Test #4: 89
Sorted test scores:
Test #1: 22
Test #2: 34
Test #3: 73
Test #4: 89
Average = 54.5
Find the errors
int sum(int x, int y)
{
int result; result = x + y;
}
An integer is said to be a perfect number if the sum of its divisors, including 1 (but not the number itself),
is equal to the number. For example, 6 is a perfect number, because 6 = 1 + 2 + 3. Write a function
isPerfect() that determines whether parameter number is a perfect number. Use this function in a
program that determines and prints all the perfect numbers between 1 and 1000. Print the divisors of
each perfect number to confirm that the number is indeed perfect. Challenge the power of your computer
by testing numbers much larger than 1000.
Ravan's dream is to win tic-tac-toe championship.to accomplish this he practices alone at home to learn the strategies of the game . your task is to identify the cell where Ravan should place his third piece so that he wins the game. Assume that each cell in the tic-tac-toe board is marked with a number as shown in the below
TIC TAC TOE
0 1 2
3 4 5
6 7 8
input:
The first line of input contain two space-seperated integers representing the cells where Ravan has placed his first two pieces
output:
output should be a single line integer representing the cell where ravan should place his final piece
explanation
sample Output 1 :
ravan's first two moves are 0 and 1 so he not 2 to win the game .because it will complete the first row so the out put is 2
sample Output 2 :
ravan's first two moves are 0 and 3 so he not 6 to win the game .because it will complete the first row so the out put is 6
Instructions:
Using the do…while() loop, continuously scan for integers, but add up only all the positive integers and store the total in one variable.
The loop shall only be terminated when the inputted integer is zero. Afterwards, print out the total of all inputted positive integers.
Input
1. A series of integers
Output
The first multiple lines will contain message prompts to input the integers.
The last line contains the total of all positive integers inputted.
Enter·n:·2
Enter·n:·3
Enter·n:·4
Enter·n:·-1
Enter·n:·-5
Enter·n:·1
Enter·n:·0
Total·of·all·positives·=·10
Instructions:
Continuously ask for floating point values (decimal numbers) using the do…while() loop, sum them all up, and store the total into one variable.
The loop shall only terminate for the following reasons:
A negative decimal number is inputted (but still included in the total sum)
The total sum reaches 100.0 or more
Input
1. A series of float numbers
Output
The first multiple lines containing message prompts for float numbers.
The last line contains the sum with 2 decimal places.
Enter·a·number:·1.1
Enter·a·number:·1.2
Enter·a·number:·1.3
Enter·a·number:·1.4
Enter·a·number:·-1.0
Sum·=·4.00
Instructions:
Using a do…while() loop, continuously scan for characters (one per line) and print it out afterwards. Remember to place a space before the character's placeholder when scanning so that the newline characters will be ignored and the correct values will be scanned.
The loop shall terminate due to either of the following reasons:
The inputted character is a vowel
The number of inputted characters has already reached 5.
For all of the test cases, it is guaranteed that if the number of inputted characters is less than 5, then there must be a vowel from among the inputted characters. Also, it is guaranteed that all the characters are in lowercase.
Input
1. A series of characters
Output
Multiple lines containing message prompts for characters.
Enter·a·character:·c
c
Enter·a·character:·f
f
Enter·a·character:·a
a