Note: We need an author for this blog. Willing people contact Us......

Thursday, 17 November 2016

Dev C++, adding two integers using functions

#include <iostream>
 using namespace std;
 long add(long, long);
float add(float, float);

int main()
{
   long a, b, x;
   float c, d, y;
   cout << "Enter two integers\n";
   cin >> a >> b;
   x = add(a, b);
   cout << "Sum of integers: " << x << endl;
   cout << "Enter two floating point numbers\n";
   cin >> c >> d;
   y = add(c, d);
   cout << "Sum of floats: " << y << endl;
   return 0;
}
 long add(long x, long y)
{
   long sum;
   sum = x + y;
   return sum;
}

float add(float x, float y)
{
   float sum;
  sum = x + y;
  return sum;
}

No comments:

Post a Comment

Contact us

Name

Email *

Message *