DevJourney · code I wrote while learning

Perfect Square Finder

2 items

README.md

Perfect Square Finder

Single File Programming Question

Problem Statement

Alex is studying mathematical patterns and wants to identify all perfect squares from a list of integers. A perfect square is a number that is the square of an integer (e.g., 0, 1, 4, 9, 16, etc.).

Write a program that:

Reads a number n representing the number of integers in the list. Reads n space-separated integers. Saves the integers in a file named integers.txt. Reads the integers from the file, identifies the perfect squares, and writes them to a file named perfect_squares.txt. Prints each perfect square to the console. If no perfect squares are found, prints and writes "No perfect squares found" to the file.

Input:

format :

The first line contains an integer n, the number of elements in the list.

The second line contains n space-separated integers.

Output:

format :

Print each perfect square to the console, one per line, and save it in perfect_squares.txt.

If no perfect squares exist, print and write "No perfect squares found".

Refer to the sample output for the formatting specifications.

Code constraints : 0 ≤ numbers ≤ 104

1 ≤ n ≤ 100

Sample test cases :

Input 1:

4
4 9 10 16
Output 1 :
4
9
16
Input 2 :
4
0 2 25 30
Output 2 :
0
25
Note :
The program will be evaluated only after the “Submit Code” is clicked.
Extra spaces and new line characters in the program output will result in the failure of the test case.
Marks : 10
Negative Marks : 0