Write a program to find maximum and minimum element in an array
- #include <stdio.h>
- int main()
- {
- int myArray[]={2, 65, 17, 3, 32};
- int Max, Min;
- Max=myArray[0];
- Min=myArray[0];
- int i, j, k;
- j=k=0;
- for(i=1; i<5; i++) {
- if (myArray[i] > Max) {
- Max=myArray[i];
- j=i;
- }
- else if(myArray[i] < Min){
- Min=myArray[i];
- k=i;
- }
- }
- printf("Max:myArray[%d]=%d, Min:myArray[%d]=%d\n", j, Max, k, Min);
- return 0;
- }
একটি মন্তব্য পোস্ট করুন