Preview:
#include<stdio.h>
// Author- Khadiza Sultana
// Date- 10/8/2024
// printing all even squares from 1 to n
#include<math.h> // includin math.h library for the pow function. We can simply write i*i instead

int main() { 
    int n;
    printf("Enter a number: ");
    scanf("%d", &n);
    
    int i = 1;
    while(pow(i,2)<= n) // checking if i^2 is equal to n or not. If yes then the loop is stoped. If no then continue
    {
        int square = pow(i,2); // storing the squares of the numbers
        if(square % 2 == 0) // checking if the squares are even or not
        {
            printf("%d\n", square);
        }
        i++; // incrementing i
    }
    
    return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter