Array and Strings – Arithmetic – Problem #3
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Write a C program to fill a single dimensional integer array of maximum size 50 with random integral numbers in the range [10, 100] by appropriately calling the rand) library function. User will first enter the number of such random numbers to be generated (maximum 50). Display the array contents. Then, starting with the first (i.e., 0th element in the array), interchange pairs of numbers present at consecutive even positions, only if the first is larger than the second. Count the number of interchanges made. Display the contents of the array after all the interchanges and the number of interchanges. For example, if the original array is [10,9,23,46,34,67,21], then the array alter the interchanges would be [10,9,23,46,21,67,34], number of interchanges =1.