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
Instructions:
Using a do...while() loop, continuously scan for random integers that will be inputted by the user and print out its square, separated in each line.
Once the inputted value is 0, it will still print out its square value but should then terminate the loop afterwards. Use this concept in making your loop condition.
Input
1. Series of integers
Output
Multiple lines containing message prompts for integers and their squares.
Enter·n:·2
Square·=·4
Enter·n:·6
Square·=·36
Enter·n:·0
Square·=·0
given a of M numbers and a postive integers N, print the sum of numbers whose position in the list is divisible by N .consider that the position of numbers range from 1 to N
INPUT:
the first line contains two-spaced integers N,M
the second line contain M space-seperated integers.
output:
print a single integer representing the requried sum
explanation:
Sample Output1
Given N=1 , M=7
and the number_list=[4,8,6,6,7,9,3]
As every position is divisible by1,
4+8+6+6+7+9+3=43
so the output should be 43