rabbinur

To find out the smallest number by using array

Aug 13th, 2012
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<conio.h>
  3. #define n 4
  4.  void main()
  5. {
  6.    int i;
  7.    float small,  balance[n]={199,3,7.6,-8};
  8.    small=balance[0];
  9.    clrscr();
  10.    for(i=0; i<n; i++)
  11.    cout<<balance[i]<<" ";
  12.    //another loop do the array element comparing
  13.    for(i=0; i<n; i++)
  14.    {
  15.     if(small>balance[i])
  16.        small=balance[i];
  17.    }
  18.     cout<<"\n searching..."<<endl;
  19.     //for result presentation
  20.     cout<<" the smallest value in the given array is ="<<small<<endl;
  21.     getch();
  22. }
Advertisement
Add Comment
Please, Sign In to add comment