Anda di halaman 1dari 13

Questions:

1.Extract the even digits from a given number.


Ex1: input=1234
Output=24
Ex2: input1=1357
Output=0
2.Factorial of individual digits in a given number and store it in output array.
Ex: input=123
Output[]={1,2,6}
3. Reverse the given number.
Ex: input=1234
Output=4321
Br: if input is negative store -1 to output
If input is greater than 32676 store -2 to output.
4.Write a program to print the next prime number.
Ex: input:9
Output:11
Br: if input is negative store -1 to output
If input is greater than 32676 store -2 to output.
5.Write a program to print the non-intersecting elements from given two array
Ex:input1[]={1,2,3}
Input2[]={2,3,5}
Input3=3
Output[]={ 1,5}
Br: if any element Is negative in input1 or input2 store -1 to output

If input size is negative store -2 to output.


6.Write a program to sum the given numbers in a given array and find the average.If the
input array is greater than or equal to the average print the array.
Ex: input1={10,20,30,40,50}
Output={30,40,50}
Br: if any of input array is negative store -1 to the output .
7. Calculate grade of the students
input1:{1,56,2,86,3,96,4,75}-{id,mark,id....}
input2:8
Conditions: mark >=90 grade=1
mark>=80 and<90 grade=2
>=70 and<80 grade=3
<70 grade=0
op={1,0,2,2,3,1,4,3}-{id,grade,......}
br:

if input2 is negative store -1 in output1


if any element in array is negative store -2 in output1

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

9. 2 arrays will be given in the following format.


a={id,marks,id,marks,id,marks. . . .so on}
b={id,marks,id,marks,. . .so on}
Compare student ids in both arrays. If any id matches, compare corresponding id's marks in both
arrays and print largest. If id doesn't match print corresponding score.
if a={1,78,2,94,3,76,6,90} b={1,80,2,90,3,80,4,56}

output={1,80,2,94,3,80,4,56,6,90}

br:

if input2 is negative store -1 in output1


if any element in array is negative store -2 in output1

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:

if input2 is negative store -1 in output1


if any element in array is negative store -2 in output1

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}

18.Greatest of the three given inputs


Ip1: 3, ip2: 1,ip3:6

op:6(size of the array)

19.Inserting given element into sorted array


Ip1:{1,9,7,8,5,3,4,2} ,ip2:8(size of the array), ip3:6

op:{1,2,3,4,5,6,7,8,9}

20.Remove repeating elements and sort


Ip1:{2,3,7,4,5,2} ,ip2:6(size of the array)

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.

29.WAP to find the strong number.


30.WAP to check whether the first element and middle element in an array is same. If same
print 100 else print the First element.

31.WAP to sum the common elements in the given two arrays.


Eg:input1={1,2,3,2}

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}

33.Display the second smallest divisor of the given number


Input=6
Factors of 6 = {1, 2, 3, 6}
Output=2
B.R:
I/p=negative
o/p=-1
I/p= greater than 32767 o/p=-2
34.Sum of digits which is less than 5
Input=4359
Output=7
B.R:
I/p= all digits greater than 5 (6677) o/p=1
I/p=negative
o/p=-2
35.Repeated even numbers count
Input1= {2, 3, 4, 5, 2, 4}
Input2=6
Output=2
B.R:

I/p1=any negative elements o/p=-1


I/p2=size of an array negativeo/p=-2

36.Sum of even digits in a given no


Input=2743
Output=6
B.R:
I/p=negative
o/p=-1
I/p= greater than 32767 o/p=-2
37.Salary will be given. 20% of salary for food, 30% of salary for travel. 2% of salary will
be given for extra shifts. Find the savings.
Input1= 7000 (salary)
Input2=5 (shifts)
B.R:
I/p1= greater than 7000
I/p1= negative
I/p2=negative

o/p=-1
o/p=-2
o/p=-3

38.Sum of multiples of a number till N natural number.

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.

40.Sort the given array in descending order.


BR: If array size is negative, store -2 to the first index of the output array.
If any of the array elements are negative, store -1 in the first index of output array.
41.Find the Sum of digits less than 5 in an input variable. If all the digits are greater than 5,
store 1 in the output variable.
If the input is negative, store -1 in the output. If the input is greater than 32627, store -2 in the
output.

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................}\

53..sum of multiples of 5 upto n natural numbers.


54.remove the repeated elements from an array and avg the largest 3 numbers.
{1,2,2,3,4,4,5,5}={1,2,3,4,5}avg of largest 3 numbers.

55.celcius to farhenheit conversion.

56. if age>18, save 5 in the new array else save 4.


Add the new array elements and save it in output variable.
Input1[]={23,54,67,12,45,17,9,66}
input2=8
BR:
if input1<0, output=-1;

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

61.Average of prime indices in an array


If index is 0 asume it to be 1 ,etc., and then find whether it is prime or not and then proceed?
Br 1:
Array size is ve or even store -2
Br 2
If any array elements are ve store -1

62.Reverse the elements given in the array using mid formula


Eg :{25,40,60,34,21}
Op={21,34,60,40,25}
Br1
If any array elements are ve store -1 to output array
(not given where we have to store)
Br 2
If array size is ve store -2 to output array
(not given where we have to store)
63. Given key and index, find the odd key and find the average of those
Corresponding index values
Input1[]: {1,3,2,1,3,7,4,8}
Input2: 8
Output1: 5
64. Given an Array and its size, find the count of elements which ends with 3
Input1: {43,53,22,11,33,763}
Input2: 6
Output1: 4
65.write a program to find the elements which are not present in the second array.
br 1) store -1 to the first element of the output array if any of element is negative.
2) store -2 to the first element of the output array if the size of the array is -ve.

Anda mungkin juga menyukai