ASSIGMENT NO.- 3 (Related to Array and Pointers)
-
C program to find Armstrong numbers between 1 to n Solution Input Enter lower limit: 1 Enter upper limit: 1000
Output Armstrong numbers between 1 to 1000 are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 370, 371, 407
-
WAP to implement the Formula n C r. Solution Input : n = 5, r = 2 Output : 10
-
WAP to print the following sequence of numbers 0,1,1,2,3,5,8,13,21,……….. Solution Input:9 Output: 0 1 1 2 3 5 8 13 21
-
Twenty five numbers are entered from the keyboard into an array. The number to be searched is entered through the keyboard by the user. Write a program to find if the number to be searched is present in the array and if it is present, display the number of times it appears in the array. Solution Enter number : 9 Enter number : 2 Enter number : 3 Enter number : 4 Enter number : -1 Enter number : 2 Enter number : 35 Enter number : 47 Enter number : 56 Enter number : 3 Enter number : 3 Enter number : 2 Enter number : 3 Enter number : 3 Enter number : 3 Enter number : 4 Enter number : 5 Enter number : 9 Enter number : 7 Enter number : 8 Enter number : 5
Enter the number you want to search : 3
3 is present in the data 6 times.
-
Twenty five numbers are entered from the keyboard into an array. Write a program to find out how many of them are positive, how many are negative, how many are even and how many odd. Solution Enter a number : 7 Enter a number : 8 Enter a number : 9 Enter a number : 10 Enter a number : 11 Enter a number : 14 Enter a number : 9 Enter a number : 5 Enter a number : 6 Enter a number : 7 Enter a number : 5 Enter a number : 3 Enter a number : 7 Enter a number : 9 Enter a number : 5 Enter a number : 4 Enter a number : 6 Enter a number : 7 Enter a number : 9 Enter a number : 12 Enter a number : 36 Enter a number : 1 Enter a number : 4 Enter a number : 5
Data contain 25 positive, 0 negative, 0 zeroes, 10 even and 15 odd numbers
-
Write a program using array in which find maximum and second maximum number. Solution 1,3,2,5,6,3 Output: 6 5
-
WAP to merge the two array A and B of size m and n respectively in one sorted array C of size M + N Solution Input Input first array elements: 1, 4, 6, 9, 15 Input second array elements: 2, 5, 8, 10 Output Merged array in ascending order = 1, 2, 4, 5, 6, 8, 9, 10, 15
-
There are two arrays A and B. A contain 5 elements, whereas, B contains 4 elements. Write a function to create an array C that contain only those elements that are common to A and B. Solution Input : arr1[] = {1, 3, 4, 5, 7} arr2[] = {2, 3, 5, 6} Output : Intersection : {3, 5}
-
Write a program to insert the new element in array at given location k. Solution Enter size of the array : 5 Enter elements in array : 2 3 4 6 8 Enter index should be less than 5:1 Enter new element : 12
before insertion :2 3 4 6 8 after insertion :2 12 4 6 8
-
Write a program to search the location of a given element in array. Solution Please Enter the size of an array : 5
Please Enter 5 elements of an array: 2 3 4 1 5
Please Enter the Search Element : 2
We found the Search Element 2 at Position 1
-
WAP to print the sum of the diagonal element of the M*N square matrix. Solution
Please Enter Number of rows and columns : 3 3
Please Enter the Matrix Elements 10 20 30 40 50 60 70 80 90
The Sum of Diagonal Elements of a Matrix = 150
-
Write a program to multiply any two matrixes also with condition of matrix multiplication. Solution Input elements of matrix1: 1 2 3 4 5 6 7 8 9 Input elements of matrix2: 9 8 7 6 5 4 3 2 1 Output Product of matrices = 30 24 18 84 69 54 138 114 90
(22)(22) (23)(32)==(22) (24)(32)==(43)
-
WAP to find the maximum element in an array & find how many times it is coming in an array of size n. Solution Enter the number of elements in array 5 Enter 5 integers 10 20 20 5 3 Maximum element is 20 and it’s coming 2 times
-
WAP to print the transpose of m*n matrix using pointer Solution How many rows and columns in the matrix:- 3 3
Enter the elements:- 1 2 3 4 5 6 7 8 9
The transpose of matrix is:- 1 4 7 2 5 8 3 6 9