4 Array
4 Array
4.WAP in C to find sum of all array elements. 17. WAP in C to sort 1st 3 element of array .
i/p: int a[5]={10,20,30,40,50}; i/p: int a[7]={11,33,22,2,9,1,6};
o/p: 150 o/p: 11 22 33 2 9 1 6
5.WAP in C to find sum of 1st digit of all array WAP to C to insert 99 on 0th index in same array .
i/p: int a[5]={123,23,89,3425,721}; i/p: int a[7]={2,3,5,7,11,13 }, in=0, num=99;
o/p: 1+2+8+3+7 ----> 21 o/p: int a[7]={99, 2,3,5,7,11,13};
6.WAP in C to delete 1st digit of all array elements. WAP to C to insert 51 on 3rd index in same array .
i/p: int a[6]={12,234,321,45,654,1234}; i/p: int a[7]={2,3,5,7,11,13 },in=3 ,num=51;
o/p: int a[6]={2 , 34, 21, 5, 54, 234}; o/p: int a[7]={2,3,5,51,7,11,13};
7.WAP in C to print binary of all elemets in array . WAP to C to insert 10 on sorted place in sorted array
i/p: int a[5]={10,100,1000,100,10} i/p: int a[7]={2,3,5,7,11,13 }, num= 10;
o/p: o/p: int a[7]={2,3,5,7, 10, 11,13};
8.WAP in C to delete 0th bit of all array elements. 21. WAP to C to insert 99 on 0th , 88 on 1st index in
i/p: int a[5]={12,10,35,63,512}; same array .
o/p: int a[5]={ 6, 5,17,31,256}; i/p: int a[9]={30,11,45,34,14,8 ,50 },num=99 ;
o/p: int a[9]={99,88, 30,11,45,34,14,8, 50};
9.WAP in C to count all set and clear bit array .
i/p: int a[5]={10,15,64,100,511}; 22. WAP in C to merge 2 array into 3rd array .
o/p: set count =19 , clear count=141 i/p: int a[3]={1,5,7}; b[3]={11,22,33};
o/p: int c[6]={1,11,5,22,7,33};
10. WAP in C to store set bit count to another array.
i/p: int a[5]={10,15,64,100,511}; 23. WAP in C to merge 2 array into 3rd array .
o/p: int b[5]={2 , 4, 1, 3, 9 };
i/p: int a[2]={1,5}; b[4]={11,22,33,44};
WAP in C to count -ve ,+ve, even , odd ele in array . o/p: int c[6]={1,11,5,22,33,44};
i/p: int a[10]={-11,11,12,-12,9,8,-3,10,22};
o/p: +ve = 6 , -ve = 3 , odd = 2 , even = 4 24. WAP in C to delete 0th index element from array
i/p: int a[5]={99,88,77,66,55}, in=0;
12. WAP in C to print Smallest element in array. o/p: int a[5]={88,77,66,55};
i/p : int a[6]={2,2,3,5,5,4};
o/p : res = 2 25.WAP in C to delete 2nd index element from array
i/p: int a[5]={99,88,77,66,55}, pos=2;
WAP in C to print second largest element in array. o/p: int a[5]={99,88,66,55};
i/p : int a[7]={2,2,3,5,5,4,4};
o/p : second large = 4 26. WAP in C to delete 2nd,3rd index from array .
i/p: int a[5]={99,88,77,66,55}, pos1=2, pos2=3;
WAP in C to print second smallest element in array. o/p: int a[5]={99,88,55};
ARRAY ARRAY
27. WAP in C to delete odd elements from array . WAP in C to left rotate array 2 times in same array.
i/p: int a[6]={11,12,14,13,15,18}; i/p: int a[7]={11,21,31,41,51,61,71};
o/p: int a[6]={12,14,18}; o/p: int a[7]={31,41,51,61,71,11,21};
28. WAP in C to delete -ve elements from array . 42. WAP in C to shift all -ve elements to right side in
i/p: int a[6]={-11,12,-14,13,-15,-18}; same array.
o/p: int a[6]={12, 13}; i/p: int a[7]={-1,22,3,-4,-8,33,77};
o/p: int a[7]={22,3,33,77,-1,-4,-8,};
WAP in C to delete duplicate elements from array .
i/p: a[10]={3,3,2,4,4,1,2,3,7,9} 43 .WAP in C to shift all odd elements to right side
o/p: a[10]={3,2,4,1,7,9}; in same array.
30 WAP in C to delete even duplicate ele from array. i/p: int a[7]={11,22,22,44,55,33,88};
i/p: a[10]={3,3,2,4,4,2,5,3,4,9} o/p: int a[7]={22,22,44,88,11,55,33};
o/p: a[10]={3,3,2,4,5,3,9};
44.WAP in C to shift all 0 to left side in same array.
WAP in C to count all duplicate elements from array. i/p: int a[7]={11,0,0,44,0,33,0};
i/p: a[10]={3,3,2,4,4,2,5,3,4,9} o/p: int a[7]={0,0,0,0,11,44,33};
o/p: 3 ->3 times ,2-> 2 times , 4-> 3 times
WAP in C to print 1st perfect and pos form array .
WAP in C to product of digit of all array elements. i/p: int a[5]={2,4,6,28,6};
i/p: int a[5]={11,202,234,456,90}; o/p: num= 6, pos= 2
o/p: int a[5]={1, 0, 24, 120, 0};
46.WAP in C to store 1st 7 prime number in array .
WAP in C to store factorial of array in another array. i/p: int a[7];
i/p: int a[4]={ 4, 5, 6, 4}; o/p: int a[7]={2,3,5,7,11,13,17};
o/p: int b[4]={24,120,720,24}
47. WAP in C to delete perfect number from array .
34. WAP in C to print and count prime in array . i/p: int a[6]={6,6,7,28,6,5,24};
i/p: int a[7]={3,4,5,6,7,8,9}; o/p: int a[6]={7,5,24};
o/p: 3 5 7 , count= 3
35.WAP in C to print and count perfect in array . WAP in C to replace prime index ele with 0 in array.
i/p: int a[7]={3,4,5,6,7,28,9}; i/p: int a[8]={11,22,33,44,55,66,77,88};
o/p: 6 28 , count= 2 o/p: int a[8]={11,22,0 ,0 ,55,0 ,77,0 };
36. WAP in C to print and count strong in array . WAP in C to store prime index ele in another array.
i/p: int a[7]={2,4,2,6,145,28,1}; i/p: int a[8]={11,22,33,44,55,66,77,88};
o/p: 2 2 145 1 ,count= 4 o/p: int b[8]={33,44,66,88};
WAP in C to print and count armstrong in array . 50. WAP in C to delete all strong num from array .
i/p: int a[7]={22,4,21,6,153,28,11};
o/p: 4 6 153 ,count= 3 i/p: int a[6]={2,145,2,14,3,2};
o/p: int a[6]={14,3};
WAP in C to right rotate array 1 times in same array.
i/p: int a[7]={11,21,31,41,51,61,71}; 51. WAP in C to delete odd palindrome number
o/p: int a[7]={71,11,21,31,41,51,61}; from array .
i/p: int a[6]={22,141,222,45,33,77};
WAP in C to right rotate array 3 times in same array. o/p: int a[6]={22,222,45};
i/p: int a[7]={11,21,31,41,51,61,71};
o/p: int a[7]={51,61,71,11,21,31,41}; if you found any mistake or doubts send mail to
pawan.ky@vectorindia.org [ Pawan KY ]
WAP in C to left rotate array 1 times in same array.
i/p: int a[7]={11,21,31,41,51,61,71}; after learning function topics write above all 51
o/p: int a[7]={21,31,41,51,61,71,11}; program using function .