Posts

Showing posts from August, 2017

Unique and smallest bid finder algorithm and program

Nowadays, online sites like Flipkart and Amazon are running competitions to post a unique and smallest bid on a product. Here is the source code in C to find the unique and smallest bid. #include <stdio.h> int main() { int n,i,j,flag; float bid[ 100 ],unique; printf ( "Enter the number of bids\n" ); scanf ( "%d" ,&n); printf ( "\n" ); printf ( "Enter the bids\n" ); for (i= 0 ;i<n;i++) { scanf ( "%f" ,&bid[i]); } unique=bid[ 0 ]; for (i= 1 ;i<n;i++) { flag= 0 ; for (j= 0 ;j<i;i++) { if (bid[j]==bid[i]) flag= 1 ; } if (flag== 0 &&bid[i]<unique) unique=bid[i]; } printf ( "The unique and smallest bid is %f" ,unique); }