Write A C Program To Interchange The Largest and Smallest Numbers in The Array
Write A C Program To Interchange The Largest and Smallest Numbers in The Array
b) Write a C program to implement a liner search. c) Write a C program to implement binary search
1. Write a C program to interchange the largest and smallest numbers in the array.
#include<stdio.h> main( ) { float value[4] = {2.5,-4.75,1.2,3.67}; clrscr(); largest(value,4); smallest(value,4); getch(); } largest(float a[], int n) { int i; float max; max = a[0]; for(i = 1; i < n; i++) if(max < a[i]) max = a[i]; printf("\n Maximum number is:%f",max); } smallest(float a[], int n) { int i; float min; min = a[0]; for(i = 1; i < n; i++) if(min > a[i]) min = a[i]; printf("\n Least number is:%f",min); } Input/ Output: Maximum Number is: 3.670000 Minimum Number is: -4.750000