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
olga2289 [7]
3 years ago
10

-Write a function is_perfect, which accepts a single integer as input. If the input is not positive, the function should return

a string "Invalid input." If the input is positive, the function should return True if the input is a perfect number and False otherwise.
Computers and Technology
1 answer:
Genrish500 [490]3 years ago
4 0

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// function

string is_perfect(int n)

{

   // string variables

   string str;

   // if number is negative

   if (n < 0)

   {

        str="invalid input.";

   }

   // if number is positive

   else

   {

      int a=sqrt(n);

      // if number is perfect square

      if((a*a)==n)

      {

          str="True";

      }

      // if number is not perfect square

      else

      {

          str="False";

      }

   }

   // return the string

     return str;

}

// main function

int main()

{

   // variables

int n;

cout<<"enter the number:";

// read the value of n

cin>>n;

// call the function

string value=is_perfect(n);

// print the result

cout<<value<<endl;

return 0;

}

Explanation:

Read a number from user and assign it to variable "n".Then call the function is_perfect() with parameter n.First check whether number is negative or not. If number is negative then return a string "invalid input".If number is positive and perfect square then return a string "True" else return a string "False".

Output:

enter the number:-3

invalid input.

enter the number:5

False

enter the number:16

True

You might be interested in
A_ is an object makerfirst program second object third class fourth method ​
liberstina [14]

Answer:

you will use the components object animator whether sjetchware or HTML

5 0
3 years ago
4.15 LAB: Password modifier
Black_prince [1.1K]

I've included my code in the picture below. Best of luck.

3 0
3 years ago
An example of phishing is: Select one: a. flooding a web server with thousands of requests for service. b. setting up a fake med
tigry1 [53]

Answer:

Option(b) is the correct answer to the given question.

Explanation:

The main objective of the Phishing to posing as a legitimate entity and trick the individuals to sharing her confidential information like information of banking details such as credit card number  and passwords etc.

Phishing is done with the help of email, telephone or etc. Sometime phishing is done by the web page and stolen the website password. Phishing provides financial loss to the individual as well as the organization.

Except for option(b) all the options are not examples of Phishing that's why they are incorrect Options.

7 0
4 years ago
Read 2 more answers
After Lola gave her friend the password to a protected website, her friend was able to remember it only long enough to type it i
Naily [24]

Answer:

Short term memory

Explanation:

Is the capacity an individual has to hold on to a small amount of information for a short period of time without altering it, it is used to remember information like phone numbers, passwords etc. It is also known as primary or active memory.

If short time memories is not rehearsed, they don't last and are easily forgotten, they actually last for about 20-30 seconds.

Aspects of short term memory :

1. Limited capacity : in a short term memory at most 7 items can be stored at a time.

2. Limited capacity : information is short lived and can be lost through distraction and with time.

3. Encoding.

4 0
4 years ago
A technician is performing Windows preventive maintenance tasks on all computers in the organization. She wants a way to create
max2010maxim [7]

Answer:

mmc.exe

Explanation:

mmc.exe is the command for Microsoft Management Console, which allows you to create, save, and open consoles.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Given that a method receives three parameters a, b, c, of type double, write some code, to be included as part of the method, th
    8·1 answer
  • What ip address cidrs are not allowed to be communicated with by our malware?
    15·1 answer
  • System inputs and outputs are produced at the end of the: A. systems analysis phase of the SDLC. B. systems planning and selecti
    12·1 answer
  • Write 2-3 lines about the Basic operations of computer
    5·1 answer
  • What is virtualization?
    11·2 answers
  • An anchor tag can be coded using which two attributes? HELP ME PLEASE!!!!
    12·2 answers
  • java Two smallest numbers Write a program that reads a list of integers, and outputs the two smallest integers in the list, in a
    6·1 answer
  • Natural language generation is focused on?
    10·1 answer
  • Heuristics are not always completely accurate.<br><br><br> Correct or wrong?
    10·2 answers
  • A large, closet-sized computer capable of simultaneously processing data for hundreds or thousands of users is most likely a ___
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!