Sunday, August 2, 2009

Write a program to find the smallest and largest element in a given array in c language?

This is Yahoo Answers, not Yahoo Do My Homework For Me.

Write a program to find the smallest and largest element in a given array in c language?
I won't write the code for you, but I'll get you started. First of all, you will have to go through the entire array. So the way I'd find the smallest element in the array would be to assign the very first value as the "smallest," then compare this value with each element in the array. If you come across a smaller value, assign that value to be "smallest" variable and continue through the array. In the end the value in the "smallest" variable actually will be the smallest. Finding the largest element in the array would essentially be the same.

white flowers

No comments:

Post a Comment