MANDALAY TECHNOLOGICAL UNIVERSITY
DEPARTMENT OF ELECTRONIC ENGINEERING
EXPERIMENT (1)
LABORATORY REPORT
FOR
SECOND YEAR EcE-22014
(SECOND SEMESTER)
Technical Programming II
Lab 1: C Arrays
Name ……………………………………………….…………………………
Roll no. ………………………………………………..….…………………...
Mandalay Technological University
Electronic Engineering Department
EcE-22014 Technical Programming
EXPERIMENT 1
CHAPTER 6, C ARRAYS
Course Outcomes
After the completion of this chapter, the students will be able to
✓ use the array data structure to represent lists and tables of values
✓ define an array, initialize an array and refer to individual elements of an array
✓ pass arrays to functions
✓ use arrays to store, sort and search lists and tables of values
Exercise 1
To find the maximum and minimum of given numbers in array.
How do you think to write a program?
First Step: This program starts with initializing:
✓ i→Helping Variable
✓ size→Indicates size of array i.e, number of elements to be sorted in array
✓ max,min→To store maximum and minimum numbers from given array
✓ a[size]→To store array elements of given size
Second Step: Taking size and array elements as input from user
✓ Enter size and print it
✓ Enter numbers in array to find max and min and print them by using for loop
Third Step: Initializing min, max to first element in array
✓ min=a[0];
✓ max=a[0];
✓ So lets take array elements say, 45, 30, 35, 32, then min=45 and max=45
Fourth Step: a[i] is compared by max and min.
✓ If it is greater than max, the value of max is replaced by the value of a[i].
✓ If it is less than min, the value of min is replaced by the valu of a[i].
✓ Iterate from 1st element till the last element in array by using for loop.
Fifth Step: Finally min and max will be printed.
Exercise
To separate even and odd numbers in array.
How do you think to write a program?
First Step: the program starts with initializing
✓ size→To store size of array
✓ i→Temporary variable
✓ a→To store array elements
Second Step: Taking size and array elements as input from user
✓ Enter size and print it
✓ Enter numbers in array to separate even and odd and print them by using for loop
Third Step: Calculating the even numbers in array
✓ For even number→if a[i]>=0i.e whether the number at position, i is greater than zero or
not just to avoid 0’s to print. If the value of a[i] is divided by 2 and then the remainder is
equal to 0 zero, the value of a[i] is even. If it is even or not, using a[i]%2==0 which is used
to identify even numbers. This is the 1st for loop.
✓ Iterate from 1st element of array till the last element in array by using for loop
Fourth Step: Calculating the odd numbers in array
✓ For odd number→a[i]>=0 and it continued to check. If the value of a[i] is divided by 2 and
then the remainder is not equal to 0 zero; otherwise the remainder is equal to 1, the value
of a[i] is odd. This is the 2nd for loop.
✓ Iterate from 1st element of array till the last element in array by using for loop.