Arrays


  1. A supermarket stores the prices of different products in an array for billing purposes. The manager wants to calculate the total cost of all products and also determine the average price of the items available in the list. The prices of N products are entered through the keyboard and stored in an array, after which the total and average price are displayed on the screen.

  2. A school examination department stores the marks of N students in a system for performance analysis. The principal wants to know how many students scored 80 or more marks and how many students scored marks between 60 and 70. The marks of all students are entered through the keyboard and stored appropriately, after which the required counts are displayed on the screen.

    Expected Output:
       Enter No. of Students: 5
       Enter Marks:90
       Enter Marks:80
       Enter Marks:65
       Enter Marks:75
       Enter Marks:58
    
       Students got >=80 is 2
       Students got between 60 and 70 is 1
                           

  3. A computer application stores numerical data in two separate arrays for calculation purposes. To generate a combined result, corresponding elements of both arrays are added and stored in a third array. The elements of two arrays are entered through the keyboard, and the resulting values are displayed after performing the addition operation.

    Expected Output:
        Enter N: 3
        Enter Value at A[0]:1
        Enter Value at A[1]:2
        Enter Value at A[2]:3
        
        Enter Value at B[0]:4
        Enter Value at B[1]:5
        Enter Value at B[2]:6
        
        Sum of Two Array is:
        C[0]:5
        C[1]:7
        C[2]:9    
                                    

  4. A travel agency keeps records of booking dates and needs to calculate the total number of days between two months for planning tour schedules. The user enters two month numbers through the keyboard, and the system calculates and displays the total number of days lying between those months according to the calendar.

    Expected Output:
        Enter Start Month:3
        Enter End Month:5
        
        31+30+31=92 
                                    

  5. Input a Matrix of M*N Order(Square Matrix) and print Diagonal Elements.

    Expected Output:
        Enter N: 3
        Enter Value at A[0][0]:1
        Enter Value at A[0][1]:2
        Enter Value at A[0][2]:3
        Enter Value at A[1][0]:4
        Enter Value at A[1][1]:5
        Enter Value at A[1][2]:6
        Enter Value at A[2][0]:7
        Enter Value at A[2][1]:8
        Enter Value at A[2][2]:9
        
        1 0 0
        0 5 0
        0 0 9
                                    

  6. Input a Square Matrix and print Cross Diagonal Elements.

    Expected Output:
        Enter N: 3
        Enter Value at A[0][0]:1
        Enter Value at A[0][1]:2
        Enter Value at A[0][2]:3
        Enter Value at A[1][0]:4
        Enter Value at A[1][1]:5
        Enter Value at A[1][2]:6
        Enter Value at A[2][0]:7
        Enter Value at A[2][1]:8
        Enter Value at A[2][2]:9
        
        1 0 3
        0 5 0
        7 0 9
                                    

  7. Sum of two Matrices of M*N order.