Write a program that will prompt the user to input ten integer values. The program will display the smallest and greatest of those values.

Input : Please input 10 numbers : 2   3  45   1   89   10   32   67   98   100
Output : Smallest number is 1
              Greatest number is 100
Gre0



  1. #include<stdio.h>

  2. void main()
  3. {
  4.     int arr[10], smallest, greatest;

  5.     printf("Please input 10 numbers : ");
  6.     for(int i=0; i<10; i++){
  7.         scanf("%d", &arr[i]);
  8.     }

  9.     for(int i=0; i<10; i++){
  10.         if(smallest > arr[i])
  11.             smallest = arr[i];

  12.         else
  13.             greatest = arr[i];

  14.     }
  15.     printf("Smallest number is %d\n", smallest);
  16.     printf("Greatest number is %d\n", greatest);
  17. }


একটি মন্তব্য পোস্ট করুন