Вы находитесь на странице: 1из 4

# Programs:

## 1.find the immediate next prime number

for eg: input:9
output:11
hint was given: input will not exceed 100

2.find the number of even numbers repeating
for eg: input:{2,2,3,3,4,4}
output:2
check for this input also ....output for {8,8,4,4,4,2,5,5} is 2
even numbers 8 and 4 are repeating.. so output is 2

3.descending order

4.salary will be given. 20% of salary for food.30% of salary for travel. 2% of s
alary ll be given for extra shifts. number of shifts will also be given.find d
savings

5.input ll be a number
find the product of odd digits and even digits seperately
sum the products
if all the digits are odd or even add 1 to the sum

6.reverse the number

7.decimal to bimary

8.input1:{1,2,2,4,3,4}-{key,value,key....}
input2:6(array size)
input3:4(value)
output:2,3( print all the keys for which the value is given in input3)
BR1: if the input3 is not in input1 store op=-1
BR2: if input2<0 op=-3
BR3:if any element in input1<0 op=-2

input1:{1,56,2,86,3,96,4,75}-{id,mark,id....}
input2:8

10.input:{24,45,11,14,23}
ouput:{20,1,6}
hint: find the odd numbers in the array{45,11,23}
multiply the digits of each number
4*5=20
1*1=1
2*3=6
*****************11. write a program to print second largest divisor of the give
n number*********
eg:input=21 divisors are {1,3,7,21}
output=7
12.wap to find factorial of individual digits in a given input number and store
it in an array
eg:123
output={1,4,9}
///////13.wap to print only non intersecting elements from the t
wo given arrays. size of both input arrays is equal.
eg:input1={1,2,3,4,5}
input2={2,3,6,7,8}
output={1,4,5,6,7,8}

/////14.wap to print the elements in first array which is not pr
esent in second array.size of both input arrays is equal.
eg:input1={11,12,13,14,15}
input2={11,13,2,3,4}
output={12,14,15}
15 wap to find strong number or not
br=if element is -ve op=-1
16 wap to find the avg in gn array if any of the elemt greater than avg strore
into output variable
br=array size negative store -1.
////////17 armstrong between two ranges and find largest one in
that.
br: if any range -ve store -1
18 reverse the array elements in array,if range is odd using mid=n/2 formula
br: store -2 if elemnt is even or range -ve,store -1 if any one element is neg
ative
19. del -ve elemts in array nd sum positive ones
br: store -2 if al
l r -ve elemts,store -1 if size -ve
20. wap to display milg of bike based on cc of engine
if cc is 100-125 mil : 75
if cc is 126-135 mil : 70
if cc is 136-145 mil : 65
if cc is 146-155 mil : 60
if cc is 156-165 mil : 55
if cc is 166-175 mil : 50
if cc is 176-200 mil : 45
if cc is 200-220 mil : 40
br : if size is gr8 than 220 op=-2,if size is -ve or less than 100 op=-1;

21.Write a program to find the average of elements present in the prime indices
of the given array.
br:index starts from 1.

22.smallest of four numbers.
Br: If input1<0 op=-1
input1>32767 op=-2
23.Based on input3 perform various operations
input1 & input2 are numbers.
BR: if input3<0 op=-1
BR: input3=1 op=ip1+ip2;
Br:input3=2 op=difference of ip1 &ip2
Br:input3=3 op=mul of ip1 and ip2
Br: input3=4 op=divide input1 by input2
br: if input3 other than above op=-2
24.Add multiples of "input1" till input2 and store in output1
input1=3
input2=15
output1=45
25.input1={id1,3,id2,3,id3,6,id4,6,id5,9}(id,value,id,....)
input2=10(array size)
add values next to odd id and find average.
output1=18/3=6
br:input1[i]<0 op=-1
input2<0 op=-2
//////////////////////////*****26.input1={12365,12396,12125,12256}
input2=4(arraysize)
input3=123(find this pattern in array and print next numbers in output array)
output1={65,96}
br:input1[i]<0 op=-1
input2<0 op=-2
27.sort array1 in ascd order, array2 in desc order. Multipy 1st elmt in arr1 wi
th last elmt in arr2 and so on. (criscross multiplication) and store in output1
array.
28.extract the even digit
for eg: input:4512
output:42
input:1315
ouput:0
29.find the diff between consecutive elements in array . assign the largest diff
erence to the output
eg: ip={4,10,6,5,3}
op=6;(store the difference between consecutive elements in a seperate arr
ay)
30. Smallest of four digits.

///////////////////31. Input1=[1,2,3,4,5] input2=[3,4,5,6,7]
output {3,4,5}
compare the two input array save the common element in a different array. Sort t
he resultant array and save it to output array.
32. Sort the input array and insert an element to the sorted array.
33. Input1[]={1,3,5,77,85,66,43,6,2}
Input2[]={65,1,23,3,85,67,34,85,2}
Input3=9
compare the two array for the similar element. ADD the similar elements.
Ans: 1+3+85+2=91
34. Input1[]={23,54,67,12,45,17,9,66}
input2=8
if age>18, save 5 in the new array else save 4.
Add the new array elements and save it in output variable.
35. Input1[]={1,3,5,77,85,66,43,6,2}
Input2[]={65,1,23,3,85,67,34,85,2}
Input3=9
Save the common elements from both the array in an new array sort the array and
save it to the output array.

36.sum of even digits in a given number

37.remove the negative elements in a array and sort the remaining elements

38.consecutive elements for a given array
example:
input2=4[array size]
input1={2,4,7,8}
output1={3,5,8,9}

//////////////////////39.input3 must be the size of two arrays input1 and input2
compare the two arrays and store the dissimilar elements in the output array.
example:
input3=4[array size]
input1={2,4,7,8}
input2={3,4,8,9}
output1={2,7,3,9}

///////40.consider input2 as array size and firs
t index as key and second index as value. value must be stored in input3.store a
ll the key values in the output array. i.e. store the numbers before the repeati
ng numbers.
2)if elements in the input array is negative output1[0]=
-2
3)if there is no key values output1[0]= -1
example:
input2=8
input1={1,4,2,4,3,4,5,6}
input3=4
output1={1,2,3}

41.find the largest armstrong number among the given input range.
example: range is, input1 =300 between input2=500
output1=407

42.second smallest number in a array

43.second largest divisor of a given input
example:input1=21 (divisors of 21 are 1,3,7,21)
output1=7

44.smallest of 4 inputs without using array

45.number of numbers repeating in an array

46.store the repeated elements in a array and sort them in ascending order

47.factorial for a given number. if number is greater than 7 output should be -1
.

48.print the digits count in the following format.
example:
input1={1,23,2,34,456,67}
output1={1,no of single digits,2, no of 2 digits and so on}
output1={1,2,2,3,3,1}