Computer Science, asked by mrvinay8614, 1 month ago

Given a number N, find the next perfect
square greater than N.
Input Format:
Integer input from stdin.
Output Format:
Perfect square greater than N.
Example Input:
10
Output:
16

Answers

Answered by anindyaadhikari13
3

\textsf{\large{\underline{Solution}:}}

The given problem is solved using language - Python.

from math import sqrt

n=int(input('Enter an integer number: '))+1

while int(sqrt(n))!=sqrt(n):

   n=n+1

print('Next Perfect Square Number is:',n)

\textsf{\large{\underline{Explanation}:}}

  • An integer number is taken as input.
  • A loop is created which run till any perfect square is found. After each iteration of loop, the value of the variable 'n' is incremented by 1.
  • When the loop is terminated, the next perfect square is found. So, it is displayed on the screen.

\textsf{\large{\underline{Sample I/O}:}}

#1

Enter an integer number: 10

Next Perfect Square Number is: 16

#2

Enter an integer number: 16

Next Perfect Square Number is: 25

Attachments:
Similar questions