Set - 3 :
22) Get an unsorted array and convert into alternate array(alternate array- ascending order array by taking alternate elements).Half elements of array in ascending remaining half in descending.The first n elements should be sorted in ascending order and the next part should be sorted in descending and print it
Test Case Input: [1,2,3,4,5,6,7,8],8,4
Output: {1,2,3,4,8,7,6,5}
Function: fn_name(input array, length of array, no of digits to sort (here 3)) Fn_name(input array, 8,4)
23)
Given 5,1,4,7,9....... do alternate sort (odd position sorting) for this..and print
4,5,9
24) Find the occurance of a substring in a parent string
25) Write a program to rotate a matrix by 90 degrees.
29) Write a program to print numbers in the order of their frequency of occurance. Ip: {1,1,2,2,2,3,4,4,5,5,5,5,5}. Length - 13
Op: {5,5,5,5,5,2,2,2,1,1,4,4,3}
Given Function: int *fn_name(int *arr, int length of array}
30) Write a program to print numbers in the order of their frequency of occurence. Ip: {1,22,333,44,5555,7,8,9,10}. Length - 10
Op: {5555,333,22,44,1,7,8,10}
Given Function: int *fn_name(int *arr, int length of array} Use malloc() function to get the array
32) Write a program to print the not common numbers in both the arrays. Input: Arr1 = {1,2,3,4}
Arr2= {4,5,6,7}
Length = 4
Length = 4
Output: 6
33) Write a program to remove duplicate elements in a array Ip: {1,1,1,1,2,2,2,3,3,4,5}
Op: {1,2,3,4,}
Given Function: int *fn_name(int *arr, int length of array} Use malloc() function to get the input array
34) Copying value to its corresponding index (swap values and index in an array). Input: a[0] = 2; a[1] = 0; a[2] = 3; a[3] = 1; a[4] = 5; a[5] = 4;
Output: a[0] = 1; a[1] = 3; a[2] = 0; a[3] = 2; a[4] = 5; a[5] = 4;
35) Write a program to sort numbers in an array and print the numbers with alternate digits. Use malloc() to get the input array.
Ip: {4,2,5,3,7}
Op: {2,4,7}
36) Create function that passes a @-Dmatrix via a pointer like **a, number of rows, number of colums and flag value. The primary purpose of the program is to rotate the matrix of 90 degree (left or right based on the flag 0 or 1 respectively). Return the pointer that shows the altered matrix and print if in the main function.
37) Create function that passes a a-D-matrix via a pointer like **a, number of rows, number of columns and flag value. The primary purpose of the program is to rotate the matrix by 90 degrees (left or right based on the flag 0 or 1 respectively). Return the pointer that shows the altered matrix and print if in the main function.
38) Highest common factor or GCF
41) Pattern Question:-
To print the pattern like for n=3, the program should print :
1 1 1 2
3 2 2 2
3 3 3 4
print n=6; n stands for number of lines :
1111112
3222222
3333334
5444444
5555556
7666666
42) To print the trapezium pattern. for example , we have n=4 the output should be like
1*2*3*4*17*18*19*20
- -5*6*7*14*15*16
- - - -8*9*12*13
- - - - - -10*11
43) C program to print following pyramid pattern of stars
44)
Write a c program to print Pascal triangle.
In mathematics, Pascal's triangle is a triangular array of the binomial coefficients. In much of the Western world it is named after French mathematician Blaise Pascal, although other mathematicians studied it centuries before him in India, Iran, China, Germany, and Italy.
49)
Get input as N, square the N and generate the number from 1 to N2. N=4
1*2*3*4
9*10*11*12
13*14*15*16
5*6*7*8
N=5
1*2*3*4*5
11*12*13*14*15
21*22*23*24*25
16*17*18*19*20
6*7*8*9*10
50) Obtain a output as follows: N=5
1
2*3
4*5*6
7*8*9*10
11*12*13*14*15
11*12*13*14*15
7*8*9*10
4*5*6
2*3
1
51) Write a C program to print below, when n=4 and s=3
3
44
555
6666
6666
555
44
3