
3. Using one of the loop structures, and function overloading, write function mypower(int x,int y) which calculates X', and write another function in the same code called mypower(double x,int y) which calculates X'. Test both in the main. Note: y can be negative value. Hint: x-Y =
#includeusing namespace std; class powers { private: long int result1; double result3; double result2; public: powers() { result1=1; } powers(double rst) { result2=rst; } void mypower(int x,int y) { int flag=0; if(y<0) { y=y*(-1); flag=1; } for(int i=0; i #include
using namespace std;class powers
{
private:
long int result1;
double result2;
double result3;
public:
powers()
{
result1=1;
}
powers(double rst)
{
result2=rst;
}
void mypower(int x,int y)
{ int flag=0;
if(y<0)
{ y=y*(-1);
flag=1;
}
for(int i=0; i{
result1*=x;
}
if(flag==1)
{ result3= 1/(double)result1;
cout<< " result is "<
}
else
cout<<"result is int "<
cout<
}
void mypower(double x,int y)
{
int flag=0;
if(y<0)
{ y=y*(-1);
flag=1;
}
for(int i=0; i{
result2*=x;
}
if(flag==1)
{ result3= 1/(double)result2;
cout<< " result is "<
}
else
cout<<"result is int "<cout<
}
};
int main() {powers p1;
p1.mypower(32,-2);
double zz=1.0000;
powers p2(zz);
p2.mypower(5.0,-2);
return 0;
}
#includeusing namespace std; class powers //class for overloadding function created { private: long int result1; L L L L //for storing results in the powers section double result2; double result3; public: powers() //default constructor resultl=1; powers (double rst) //parameterised constructor given here result2=rst; void mypower(int x, int y) int flag=0; //first fuciton having interger parametre if(y<0) { y=y*(-1); flag=1; //case when we have negative y.... for(int i=0; i OG Binary Search Tree Set 1 (s x CC Code, Compile & Run | Code X C There Is Alreday A Solution x (399) CORONA- Ei ose X COVID-19 Tracker | India x Constructor Overloading in x + f C codechef.com/ide C++14 (Gcc 6.3) Code gets autosaved every second 32 for(int i=0; i int flag=0; 52 53 54 TL LLLLL // doulble value wala ovverloaded mypow function 55 - if(y<0) { y=y*(-1); flag=1; 56 57 58 for (int i=0; i 78 - int main() { powers pl; pl.mypower(32,-2); //calling the function I double zz=1.0000; powers p2 (zz); p2.mypower(5.0,-2); return 0; 91 81:56 Open File Custom Input Run Run Status Successfully executed Date 2020-04-13 11:49:47 Time 0 sec Mem 16.048 kB Output result is 0.000976562 result is 0.04Know the answer?Add Answer to:
Using one of the loop structures, and function overloading, write function mypowerNot the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.Similar Homework Help Questions
Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory...
Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int * ) named ptr_1. Use ptr_1 to assign the number 7 to that dynamically allocated integer, and in another line use printf to output the contents of that dynamically allocated integer variable. Write the code to dynamically allocate an integer array of length 5 using calloc or malloc and have it pointed...
Given the incomplete program below, write two functions, one called integer and another called decimal. You...
Given the incomplete program below, write two functions, one called integer and another called decimal. You can use following incomplete program. Your assignment is to supply the necessary missing code: #include #include using namespace std; int integer (….) { //REPLACE THE … WITH THE REQUIRED PARAMETER (A DOUBLE) //WRITE HERE THE CODE TO EXTRACT THE INTEGER AND RETURN IT } double decimal (….) { //REPLACE THE … WITH THE REQUIRED PARAMETER //WRITE HERE THE CODE TO EXTRACT THE DECIMAL PORTION,...
Using C programming
Using C, create a data file with the first number being an integer. The value of that integer will be the number of further integers which follow it in the file. Write the code to read the first number into the integer variable how_many.Please help me with the file :((This comes from this question:Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int...
code in c please Concepts to Practice User-written functions math.h Description For the prelab assignment, you...
code in c please Concepts to Practice User-written functions math.h Description For the prelab assignment, you are to write a function to calculate Power (exponentiation). Your function will be called MyPower. MyPower() will raise a given double type number to a positive integer power. You may NOT call any function from math.h such as pow) in your implementation of MyPower) The main) function in your program should look exactly like this: int main(void) int i,j; for (i-1;i<5;i++) { for (j-1;j<5;j++)...
write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy....
write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...
Pointer arithmetic: a) Write a printString function that prints a string (char-by-char) using pointer arithmetics and...
Pointer arithmetic: a) Write a printString function that prints a string (char-by-char) using pointer arithmetics and dereferencing. b) Write a function “void computeMinMax(double arr[], int length, double * min, double * max)” that finds the minimum and the maximum values in an array and stores the result in min and max. You are only allowed to use a single for loop in the function (no while loops). Find both the min and the max using the same for loop. Remember...
Done in C++ using visual studio 1. Write a program with one additional function called int[]...
Done in C++ using visual studio 1. Write a program with one additional function called int[] reverseArray(int array). This function will receive an array from main and then reverse and should return the reversed array to the main to print out. Use a single array and a single loop, you’re are neither allowed to print out just in reverse order nor allowed to use another array variable to store the original array in reverse order. 2. Write a program which...
Given two complex numbers, find the sum of the complex numbers using operator overloading. Write an...
Given two complex numbers, find the sum of the complex numbers using operator overloading. Write an operator overloading function ProblemSolution operator + (ProblemSolution const &P) which adds two ProblemSolution objects and returns a new ProblemSolution object. Input 12 -10 -34 38 where, Each row is a complex number. First element is real part and the second element is imaginary part of a complex number. Output -22 28 Two complex numbers are 12-10i and -34+38i. Sum of complex numbers are =...
1. Write code for a function that receives two parameters (a,and b) by value and two...
1. Write code for a function that receives two parameters (a,and b) by value and two more parameters (c and d) by reference. All parameters are double. The function works by assigning c to (a/b) and assigning d to (a*b). The function has no return value. From main, use scanf to get two numbers, then call the function, and then display both outcome values to the output in a printf statement. 2. After part 1 is completed, write code to...
ADVERTISEMENTNeed Online Homework Help?Ask a Question
Get Answers For Free
Most questions answered within 3 hours.ADVERTISEMENTActive Questions
- Where is the error in this code sequence? String s1 = "Hello"; String s2 = "ello";...
asked 10 months ago- Financial data for Joel de Paris, Inc., for last year follow: Joel de Paris, Inc. Balance...
asked 10 months ago- Consider this reaction: Al2(SO4)3 (aq)+ BaCl3 (aq) Al2Cl6 (aq)- + 3BaSO4(s) . What is the...
asked 10 months ago- Suppose that Savneet is considering increasing her recent random sample from 20 car rentals to 40...
asked 10 months ago- Trucks arrive at an unloading terminal at an average rate of 120 per hour. Trucks arrive...
asked 10 months ago- Why are methanol and ethanol completely soluble in water while octanol is not very little soluble....
asked 10 months ago- A facilities manager at a university reads in a research report that the mean amount of...
asked 10 months ago- When the CuSO4 is rehydrated by adding water to the anhydrous compound, is this an endothermic...
asked 10 months ago- A ray of sunlight is passing from diamond into crown glass; the angle of incidence is...
asked 10 months ago- A block of mass 0.249 kg is placed on top of a light, vertical spring of...
asked 10 months ago- how do the kidneys compensate in the presences of acidosis a) trigger hyperventilate b) reserve acid...
asked 10 months ago- Question 501 pts The rental rate of capital to the firm increases. Which of the following...
asked 10 months agoADVERTISEMENT