Friday 3 June 2016

Program that accept two numbers and find power of first number up to second number.

Write a program that declares a function accepting two parameters. The first parameter is floating point number and second number is an integer. The program should multiply the floating point number by itself the number of times indicated by the integer. The function should return the result to the main function. The main function should ask the user for the floating point number and integer.It should then call the function and store the result in the variable and main function should  display it.


#include<iostream.h>
#include<conio.h>
float mutliply (float n1, int n2);
void main()
{
      clrscr();
      float num1, r;
      int num2;
      cout<<"Enter a floating point number and an integer: ";
      cin>>num1>>num2;
      r = multiply(num1, num2);
      cout<<num1<<" multiplied to itself "<<num2<<" times is : "<<r;
      getch();
}

float multiply(float n1, int n2)
{
      float n=1;
      for(int i = 0; i <n2; i++)
            n = n * n1;
      return n;
}

Share:

1 comment:

  1. Looking for the Genuine Experience Certificate with 100% Complete Verification So Contact Experienced Letter Solutions Consulting Firms Which Provide Experienced Letter with100 % Guaranteed. Contact Now- 9599119376. Or Visit Website- https://experincedletter.blogspot.com/

    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