1.#include
#include
using namespace std;
//overload sroot() for integer, longs, and doubles.
int sroot (int i);
long sroot (long i);
double sroot (double i);
int main()
{
cout << "Square root of 90.34 is: " << (sroot(90.34);
cout << "\n";
cout << "square root of 90L is: << sroot(90L);
cout << "\n";
cout << " Square root of 90 is: " << sroot (90);
return 0;
}
\\Return square root of an integer.
int sroot(int i)
{
cout << "computing integer root\n";
return (int) sqrt (( double) i);
}
\\Return square root of long.
long sroot (long i)
{
cout << "computing long root\n";
return (long) sqrt ((double) i);
}
\\Return square root of double.
double sroot (double i)
{
cout << "computing double root\n";
return sqrt(i);
}
2.//Overload the min() function.
include
#include
using namespace std;
char min(char a, char b);
int min (int a, int b);
double min (double a, double b);
int main()
{
cout << "Min is: "<cout << "Min is: "<< min(10, 20) << "\n";
cout <<"Min is: "<< min(0.2234, 99.2) << "\n";
return 0;
}
//min() for chars
char min(char a, char b)
{
return tolower(a)}
//min() for ints
int min(int a, int b)
{
return a}
//min() for doubles
double min(double a, double b)
{
return a}
3.#include
using namespace std;
//Overload sleep to accept integer or char * argument
void sleep(int n);
void sleep(char *n);
//Charge this value to fit your processor speed.
#define DELAY 100000
int main()
{
cout << '.';
sleep(3);
cout <<'.';
sleep("2");
cout << '.';
return 0;
}
//sleep() with integer argument.
void sleep(int n)
{
long i;
for( ; n; n--)
for(i=0; i}
//Sleep() with char * argument.
void sleep(char *n)
{
long i;
int j;
j = atoi (n);
for( ; j; j--)
for( i=0; i}
4.#include
using namespace std;
int main()
{
int b, e, r;
cout <<"Enter base: ";
cin >> b;
cout <<"Enter exponent: ";
cin >>e;
r = 1;
for ( ; e; e--) r=r *b;
cout << "Result: "<< r;
return 0;
}
Githiari answered the question on May 3, 2018 at 19:03
- What is the difference between parallel and direct change over strategy?(Solved)
Differentiate between parallel and direct change over strategy.
Date posted: May 3, 2018. Answers (1)
- Why is file conversion important during implementation?(Solved)
Give reasons why file conversion is important during implementation.
Date posted: May 3, 2018. Answers (1)
- Why is system testing important?(Solved)
Give reasons why system testing is important.
Date posted: May 3, 2018. Answers (1)
- What are the ways of testing new systems before use?(Solved)
List down the ways of testing new systems before use.
Date posted: May 3, 2018. Answers (1)
- What is the difference between black box testing and white box testing?(Solved)
Differentiate between black box testing and white box testing.
Date posted: May 3, 2018. Answers (1)
- What is system testing?(Solved)
Define system testing.
Date posted: May 3, 2018. Answers (1)
- What is the main task of a computer programmer?(Solved)
Give the main task of a computer programmer.
Date posted: May 3, 2018. Answers (1)
- What are the main areas considered when designing a new system?(Solved)
Discuss the main areas that are considered when designing a new system.
Date posted: May 3, 2018. Answers (1)
- What are the disadvantages of interviews as a method for collecting data?(Solved)
Give the disadvantages of interviews as a method for collecting data.
Date posted: May 3, 2018. Answers (1)
- What is system feasibility study?(Solved)
Define the term system feasibility study.
Date posted: May 3, 2018. Answers (1)
- What are the roles of a system analyst?(Solved)
Highlight the roles of a system analyst.
Date posted: May 3, 2018. Answers (1)
- What are the qualities of a good system analyst?(Solved)
Discuss the qualities of a good system analyst.
Date posted: May 3, 2018. Answers (1)
- 1. Create a class called card that maintains a library catalog entry.Have the class store a book's tittle,author,and number of copies on hand.Store the tittle and...(Solved)
1. Create a class called card that maintains a library catalog entry. Have the class store a book's tittle,author,and number of copies on hand.Store the tittle and author as string and the number on hand as an integer.Use a public member function called show() to display the information. Include a short main() function to demonstrate the class.
2.Create a queue class that maintains a circular queue of integers.Make the queue size 100 long.Include a short main() function that demonstrates its operation.
Date posted: May 2, 2018. Answers (1)
- How can technology make office work more efficient?(Solved)
How can technology make office work more efficient?
Date posted: May 2, 2018. Answers (1)
- Explain the meaning of the word diligence in relation to computers(Solved)
Explain the meaning of the word diligence in relation to computers.
Date posted: May 2, 2018. Answers (1)
- Give reasons why mobile phones are regarded as computers(Solved)
Give reasons why mobile phones are regarded as computers.
Date posted: May 1, 2018. Answers (1)
- Here is a C program. Rewrite it so it uses C++ style I/O statements.
/* convert this C program into C++ style.This program computes the lowest...(Solved)
Here is a C program. Rewrite it so it uses C++ style I/O statements.
/* convert this C program into C++ style.This program computes the lowest common denominator*/
#include
into main (void)
{
int a, b, min ;
printf("Enter two numbers: ");
scanf("%d%d",&a, &b);
min = a > b ? b:a;
for (d = 2; dif(((a%d) ==0) && ((b%d) ==0)) break;
if (d== min) {
printf("No common denominators\n");
return 0;
}
printf("The lowest common denominator is %d\n", d);
return 0;
}
Date posted: April 30, 2018. Answers (1)
- Write a C++ program that converts feet to inches.Prompt the user for feet and display the equivalent number of inches.Have your program repeat this process...(Solved)
Write a C++ program that converts feet to inches.Prompt the user for feet and display the equivalent number of inches.Have your program repeat this process until the user enters 0 for the number of feet.
Date posted: April 30, 2018. Answers (1)
- Write a program in C++ that inputs the number of hours that an employee works and the employee's wage.Then display the employee gross pay.(Be sure...(Solved)
Write a program in C++ that inputs the number of hours that an employee works and the employee's wage.Then display the employee gross pay.(Be sure to prompt for input)
Date posted: April 30, 2018. Answers (1)
- What are turnaround documents?(Solved)
What are turnaround documents?
Date posted: April 29, 2018. Answers (1)