1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lesya692 [45]
4 years ago
10

Write a program thattakes a number x and its exponent y from the user and thencalculate the result

Computers and Technology
1 answer:
miv72 [106K]4 years ago
4 0

Answer:

#include<iostream>

using namespace std;

//main function program start from here

int main(){

   //initialize the variables

  int num, exponent;

   int result=1;

   //print the message on the screen

  cout<<"Please enter the number: ";

  cin>>num;  //store the user enter value

  cout<<"Please enter the exponent: "; //print the message on the screen

  cin>>exponent;//store the user enter value

   //take a while loop for calculating th power.

  while(exponent != 0){

   result = result*num;

  exponent--;

  }

  cout<<"Result is: "<<result<<endl;

}

Explanation:

Create the main function and declare the variable.

Then, display the message on the screen for the user and store the value enter by the user in the variables by using the instruction cin.

Take a while loop and it run until the value of exponent not equal to zero.

and then repeated multiply the number with the previous value which stores in the result.

for example;

the number is 2 and the exponent is 3. Initially, the result store is 1.

then, result = 1 * 2=2

exponent--, then exponent update the value 2.

again loop executes,

result = 2* 2=4

exponent--, then exponent update the value 1.

again loop executes,

result = 4* 2=8

exponent--, then exponent update the value 0.

The same process happens in our code and it run until the exponent not equal to zero. when it reaches zero, the loop will be terminated.

and finally, print the output.

You might be interested in
As computer words get larger and larger, there is a law of diminishing returns: the speed of execution of real application progr
otez555 [7]

Answer:

Explanation:

I can pick a reason out of many, and that would be the software. The fact is that, even as they are computers and machines, the softwares themselves have particular design cap. A software that was designed for systems with a narrow word size will most likely have issues as more and more words are used on it. I don't know if you understand what I'm saying, everything has a cap, once that particular meter is approaching, systems tend to slow onwards.

When it comes to the hardware part using the same technology, it might take a longer time to do basic arithmetic on larger inputs.

When you're under using a system, it tends to have a lot of space, excess, to perform its functions, but as soon as it is nearing its limit, it will slow down so as to accommodate all the processes at once.

3 0
3 years ago
In an inspection, usually the first thing an inspector will want to see is:
pshichka [43]

Answer:

Your records and paperwork

5 0
3 years ago
Read 2 more answers
9. A change in the appearance of a value or label in a cell
alexandr402 [8]

Answer:

format

alignment

excel

=

Explanation: i'm an accountant

4 0
3 years ago
A ___ is an online collaborative event that may include such features as chat, slideshows, and PowerPoint presentations.
german

Answer:

I think Microsoft Teams

Explanation:

Microsoft Teams. Teams is a chat-based collaboration tool that provides global, remote, and dispersed teams with the ability to work together and share information via a common space. You can utilize cool features like document collaboration, one-on-one chat, team chat, and more. Microsoft Teams is also fully integrated with many other Office 365 services, such as Skype, SharePoint, Exchange, and Yammer.

5 0
3 years ago
30 POINTS !!!!!!!!
alex41 [277]

this should help! i read over the article a little bit and it seems to answer your question pretty well. https://www.snap.com.au/articles/the-pros-and-cons-of-digital-and-offset-printing.html

7 0
3 years ago
Other questions:
  • Progressively enhancing a web page for different viewing contexts (such as smartphones and tablets) through the use of coding te
    11·1 answer
  • Which major and minor keys have no sharps or flats apex?
    5·2 answers
  • What is some advice you would give someone who is just starting online learning 2 sentences
    8·1 answer
  • List the memory units inside and outside of the CPU, along with short descriptions of their
    11·1 answer
  • What is the latest date you can file the FAFSA if you're planning to start
    6·2 answers
  • This is really not a question but yall should texts me I need friends:))
    9·2 answers
  • Which UML relationships should be used between a subclass and a superclass? For example, suppose there is an interface or abstra
    5·1 answer
  • Complete the sentence. Use a ___ ___ (2 words) to find a website's URL based on keywords you specify.​
    15·1 answer
  • 8. Assuming str(rate) is "7.25," what output would be produced by the following snippet:
    15·1 answer
  • A(n) ____ is a live internet presentation that supports interactive communications between the presenter and the audience.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!