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]
3 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]3 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
Which of the following was the name of the first generation of cell phone networks?
coldgirl [10]

Answer:

1G

Explanation:

1 'G' as in first generation.

Hope this helped. :)

3 0
3 years ago
What is computing networking​
andre [41]
A computer network is a group of computers that use a set of common communication protocols over digital interconnections for the purpose of sharing resources located on or provided by the network nodes.
6 0
3 years ago
Consider the following code segment: try : inputFile = open("lyrics.txt", "r") line = inputFile.readline() print(line) _________
aleksandrvk [35]

Answer:

The answer is "except IOError:"

Explanation:

It is part of the exception handling, that stands for input/ output operation fails, this exception aeries when we attempting to access an anti-existent file, in the program so, it will give the program related errors.

  • This type of error is handled in the try block, it also allows you to prepare the deal with the exceptional block.  
  • It also helps you to hide the bugs by using code, if you handle an unexpected error.
6 0
3 years ago
The blank contains the computer's brain the central processing unit CPU
Mila [183]

The Motherboard contains the computer's brain which is the Central Processing Unit (CPU).  It is the main circuit board for the computer, containing both soldered, non removable components along with sockets or slots for components that can be removed. The motherboard holds the CPU, RAM and ROM chips, etc.

7 0
3 years ago
Which of the following describes the operating system
Marianna [84]

Answer:

Explanation:

you added no options

5 0
3 years ago
Other questions:
  • What's the risk or effect of software piracy?
    12·2 answers
  • You use a cisco 2900 router in your network. you are considering purchasing and implementing the Unifield communications feature
    8·1 answer
  • What are the features of Cobol language that make it suitable for programming business applications.
    6·1 answer
  • Suppose that a computer can read or write a memory word in 5 nsec. Also suppose that when an interrupt occurs, all 32 CPU regist
    10·2 answers
  • What is the term used to describe a computer system that can store literary documents, link them according to logical relationsh
    5·1 answer
  • Steps in the systems development life cycle​
    15·2 answers
  • Please help thank u!!!!!
    13·2 answers
  • What is this....... Iam booking train to patna. ​
    13·2 answers
  • First Computers and Technology question in 4 years..
    11·1 answer
  • In addition to good design sense, what else do web designers need to be proficient in?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!