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
jeyben [28]
4 years ago
5

Write a program that will prompt the user to enter an integer. The program should square the number and then print the squared n

umber. Repeat this process until 0 is entered as input. Use a do-while-loop to do this.
Computers and Technology
1 answer:
Kay [80]4 years ago
3 0

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// function to compute sum and product

void square(int input)

{

   // variable to store the square of number

   long long squ_num;

   calculate the square of number

   squ_num=pow(input,2);

   // print the output

   cout<<"square of "<< input<<" is: "<<squ_num<<endl;

   

}

// driver function

int main()

{

   int n;

   // read the number until user enter 0

   do{

       cout<<"enter a number!! (0 to stop):";

     // read the input from user

       cin>>n;

       // call the function to calculate square of input number

       square(n);

       

   }while(n!=0);

 

return 0;

}

Explanation:

Declare a variable "n" to read the input number from user.Call the function  square() with parameter "n".In this function, it will calculate the square  of the input number and print it.This will repeat until user enter 0 as  input.Program will ends when user give 0 as input.

Output:

enter a number!! (0 to stop):5                                                                                                                                

square of 5 is: 25                                                                                                                                            

enter a number!! (0 to stop):7                                                                                                                                

square of 7 is: 49                                                                                                                                            

enter a number!! (0 to stop):11                                                                                                                              

square of 11 is: 121                                                                                                                                          

enter a number!! (0 to stop):0

You might be interested in
What is the name used for the camera’s view from a single position?
netineya [11]
A.A shot. 
hope this helps!!
5 0
3 years ago
How many different bit strings are there of length 6 that contain the string 0000?
Elena L [17]

Answer:

It can be 100001, 100000,000001,000000

Hence, answer is 4.

its also can be found through 2C2 *2 = 2!/0! *2 =2*2 =4

Explanation:

The answer is straight forward, we have 2 empty places and we can select from 2 items, and hence its 2C2, and now we can arrange them as well, and since we can arrange in 2 ways, hence a total number of possibility = 2 * 2C2 = 4, which is the required answer.

5 0
3 years ago
3. Megan and her brother Marco have a side business where they shop at flea markets, garage sales, and estate
Neko [114]

Answer:

a

Explanation:

Megan doesn't have a registered business. She can't claim insurance

4 0
3 years ago
1. Implement the function dict_intersect, which takes two dictionaries as parameters d1 and d2, and returns a new dictionary whi
stich3 [128]

Answer:

1  

def dict_intersect(d1,d2): #create dictionary

  d3={} #dictionaries

  for key1,value1 in d1.items():       #iterate through the loop  

      if key1 in d2:   #checking condition

          d3[key1]=(d1[key1],d2[key1])   #add the items into the dictionary  

  return d 3

print(dict_intersect({'a': 'apple', 'b': 'banana'}, {'b': 'bee', 'c': 'cat'})) #display

2

def consolidate(*l1):  #create consolidate

  d3={} # create dictionary

  for k in l1:       #iterate through the loop

      for number in k:   #iterate through  the loop                               d3[number]=d3.get(number,0)+1   #increment the value

             return d 3 #return

print(consolidate([1,2,3], [1,1,1], [2,4], [1])) #display

Explanation:

1

Following are  the description of program

  • Create a dictionary i.e"dict_intersect(d1,d2) "   in this dictionary created a dictionary d3 .
  • After that iterated the loop and check the condition .
  • If the condition is true then add the items into the dictionary and return the dictionary d3 .
  • Finally print them that are specified in the given question .

2

Following are  the description of program

  • Create a dictionary  consolidate inside that created a dictionary "d3" .
  • After that iterated the loop outer as well as inner loop and increment the value of items .
  • Return the d3 dictionary and print the dictionary as specified in the given question .

5 0
4 years ago
1. A(n)
Dennis_Churaev [7]

Answer:

1.Spelling checker


2. Order of mathematical operations .

3. Series  

4. Pick from list  

5. Sum Function


6. Active Cell  

7. cell


8. Accounting format


9. Format

Explanation:

4 0
3 years ago
Other questions:
  • All wireless networks have their own name, referred to as the ________, which is used to identify the network.
    11·1 answer
  • This is the formula for the future worth of an investment over time with consistent additional monthly payments and a steady rat
    10·1 answer
  • Mintzberg's classification of organizational structure categorizes the knowledge-based organization where goods and services dep
    5·1 answer
  • Which wireless standard has bandwidth up to 54 Mbps and signals in a regulated frequency spectrum around 5 GHz?
    13·1 answer
  • QUESTION 1
    7·1 answer
  • Cellular digestion associated by what organelles?​
    5·2 answers
  • Secure shell (SSH) operates over which port by default
    9·1 answer
  • There is only one way to change line spacing in Word.
    14·1 answer
  • What is the point of brainy when other people have to answer your questions but not the cumputer
    9·1 answer
  • Flash drive DVD and hard drive are all examples of
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!