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;
}
#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;
}
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