8. Write a program to find the average of elements present in the prime indices of the given
array.
br:index starts from 1.
if input2 is negative store -1 in output1
if any element in array is negative store -2 in output1
output={1,80,2,94,3,80,4,56,6,90}
br:
10. Check whether the given number is perfect if yes print cube of that perfect no.
Br: print 1 in output1 if given number is negative
Print 2 in output1 if given number exceeds 32687
11. Compare two arrays for corresponding elements and print the largest difference to the
output
Eg: a{ 1,2,3,4}, b{7,9,3,2}, output= 7( 7-1=6,9-2=7,3-3=0,4-2=2)
br:
12. Sum of even product & odd product in a given number. If all the digits are even or odd
add 1 to the product.
Eg: 1524=1*5=5, 2*4=8, output=13(8+5)
157=1*5*7=35, output= 36(35+1)
Br: print 1 in output1 if given number is negative
Print 2 in output1 if given number exceeds 32687
13.WAP to find the sum of prime number within the given limit.
14.WAP to find the sum of first three biggest numbers in an array.
15.WAP to find the bonus of the employees based on the basic salary as input.
If basic>20000, bonus=20%basic+1500
If basic>15000, bonus=15%basic+1000
If basic>10000, bonus=10%basic+700
Else bonus=7%basic+500
16.WAP to find the sum of digits in a number.
17.1,number of one digits,2,number of two digitis,3,number of three digits}
Ip1:{1,1,333,44,321,41} . Ip2:6(size of the array)
op:{1,2,2,2,3,2}
op:{1,2,3,4,5,6,7,8,9}
op:{2,3,4,5,7}
21.Find the prime numbers in the given array and add them.
Input1[]={2,3,4,5}
Input2=4
Output=10.
Br: If any input1[]<0,output=-1.
If input2<0,output=-2.
22.Find the odd number in the given array and multiply the digits of it and display it.
Input1[]={45,24,36,13}
Input2=4
Output[]={20,13}.
Br: if any input1[]<0,output=-1.
If input2<0,output=-2.
23.In given array, if all the consecutive differences are 4 or >4, output=1.
Input1[]={2,6,12,17}
Input2=4
(diff are {4,6,5})
Output=1.
Br: if input1[]<0,output=-1;
If input2<0,output=-2.
If any diff is less than 4 , output=3;
24.In a given array ,sum the second largest number with second smallest number.
Input1[]={2,4,5,1,8}
Input2=5.
Output=7 (2+5=7).
Br:if input1[]<0,output=-1.
If input2<0,output=-2.
25.If the digit in the number is even, print the next even number in its place. Do the same
for odd.
Input-123
Output-345
BR: if input is negative, store -1.
If input is greater than 32767, store -2.
26.Smallest of 4 numbers.
BR: if any input is negative, store -1.
If input is greater than 32767, store -2.
27. The first number in array is employee id , second is the C mark, the next is SQL mark.
if the employees C and SQL marks are >=70,print their id.
Input={1,25,75,2,78,89,3,70,98.}
Output= {2, 3}
BR: if any input in array is negative, store -1.
If input size is negative, store -2.
28. If input 2 matches the first 3 digits in the array, print the next 2 digits in the output
array.
Input1= {12345, 12367, 23456}
Output= {45, 67}
Input2=123
BR: if any input in array is negative, store -1.
If input size is negative, store -2.
If input 2 is negative, store -3.
Input2={2,3,5,4} input3=4
Output=(2+3)=5.
B.R1:if any of the elements in the arrays are negative, print -1.
B.R2 :if array size is negative, print -2.
32 .Compare the ids of the given two arrays and print the highest value for that
corresponding id.
If id is same, else print the input1 ids and values first.
{id,value,id,value,..}
Input1={1,11,2,22,4,33} input2={1,22,2,11,3,44} input3=6
Ouput1={1,22,2,22,4,33,3,44}
o/p=-1
o/p=-2
o/p=-3
39.Input will be a 5 digit number in the format XXXYY. XXX is the ID and YY is the mark.
Store ID and Mark in the output array {XXX,YY}.
If input is greater than 32627,store 1 in the output variable.
42.Count the number of elements with last digit 3 in the input array and store it in the
output variable.
If the input array contains negative values, store -1 in the output.
43.The input1 is of the form {year, sale,year,sale,year,sale} input2 is the size of the array.
The output should be the year for which the sale was maximum.
Business rule:
1. If any value in input1 is negative store -1 to output.
2. If input2 is negative store -2 to output.
44.The input1 and input2 are numbers find the sum of factors of input2 up to input1.
Eg: ip1=10 ,ip2=5 op=15.
Business rule: If ip1 or ip2 is negative store -1 to output.
45. Find the sum of numbers raised to their powers up to N Eg.1+2 2+33+44 and so on where
N is input1.
Business rule: If N is greater than 10 store -1 to output.
If N is negative store -2 to output.
46.Write a program to find the average of the marks scored by the student.
If average > 80, store 1 to the output
If average > 70, store 2 to the output
If average > 60, store 3 to the output
B.R:1. If any of the marks are negative, store -1 to the output
2. If the size of the array is negative, store -2 to the output
3. If the average is greater than 99, store -3 to the output
47.Write a program to find the Armstrong number between the given range and store the
highest Armstrong number in the output.
Input1=300
Input2=400
Output1=371
B.R:If input1 is negative, store -1 to the output
If input2 is negative, store -2 to the output
48.The first index is Key the second is its value on this basis find the average of the values
of the keys present in the prime odd position.
49.Sum of positive natural numbers.
50.Average of multiples of 5 upto n, also add n value and find the output.
Eg:input1: 10
Output1: 7
51.Find the repeating elements in an array and sort the odd prime numbers in ascending
order.
52. {2000,5000,2001,8000,2003,10000} find the year with highest revenue.
{year,revenue,year,revenue................}\
57.Given case study of feedback from two companies. Count repeating elements in an
array?
Br1: if input1[i]<0 print=-1
Br2: if input2<0 print=-2
58.In a shipping management system the boxes in the Ship 1 are numbered based on the
first come first serve basis similar to the way in ship 2. But in ship 3 the numbers are given
by adding the box number of first box to the box number of second box, box number of the
second box to the box number of second last box and so on. Write a function that finds the
box number in ship. Assume the number of boxes in ship1 and ship2 to be the same as
input3 and the box numbers for ship1 and ship2 are stored in input1 and input2
respectively.
BR: If any of the elements of the array is negative store -1 to the first element of the output array.
If the size of the array is negative store -2 to the first element of the output array.
59.In the science class the teacher decided to divide the students in groups. He divided the
groups based on even and odd number and made them do a mini project. Calculate the
batch code by adding the the sum of even roll numbers in the batch
Ex: Number:34567
Batch Code: 10(4+6)
BR: If the number is a negative number then save -1 to the output variable
If the number is greater than 36756 then save -2 to the output variable
60. We have to separate the digits, if the digit is even that has to added by next even
number if not, it has to added by next odd number.
input=324
Output=546