Problem : Find the Max/largest number
Input : 20, 5, 57, 23, 2
Output : Max:myArray[2]=57
Input : 20, 5, 57, 23, 2
Output : Max:myArray[2]=57
- #include <stdio.h>
- int main()
- {
- int myArray[]={20, 5, 57, 23, 2};
- int Max;
- Max=myArray[0];
- int i, j;
- for(i=1; i<5; i++) {
- if (myArray[i] > Max) {
- Max=myArray[i];
- j=i;
- }
- }
- printf("Max:myArray[%d]=%d \n", j, Max);
- return 0;
- }
একটি মন্তব্য পোস্ট করুন