Friday 3 June 2016

Write a function that returns the smallest of three floating point numbers.

#include<iostream.h>
#include<conio.h>
float smallest (float a, float b , float c);
void main()
{
      clrscr();
      float n1, n2, n3;
      cout<< "Enter three floating point numbers: ";
      cin>>n1>>n2>>n3;
      cout<<"The smallest floating number is: "<<smallest(n1,n2,n3);
      getch();
}

float smallest (float a , float b , float c)
{
      if(a<b && a<c)
            return a;
      else if(b<a && b<c)
            return b;
      else
            return c;
}
Share:

1 comment:

  1. it although gives the correct result but after a single gap it also display 6-7 digits irrelevant digits i dont know why?

    like it gives the following output:

    enter three floating point numbers: 7
    2
    9
    the smallest floating point number is:2 9 6356740

    the execution time:0.435s

    ReplyDelete

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

About Me

My photo
A group of two, with a little hope of helping beginners to learn how to code :)
Powered by Blogger.

Comments

Facebook

Ad Home

Follow Us

Random Posts

Sponsor

Recent Posts

Header Ads

Popular Posts

Copyright © Functions in C++ | Powered by Blogger

Design by ThemePacific | Blogger Theme by NewBloggerThemes.com | Distributed By Blogger Templates20