Skip to content

Instantly share code, notes, and snippets.

@btechmag
Created May 5, 2021 04:44
Show Gist options
  • Save btechmag/4d89a72c424126c3306b10a43bc49387 to your computer and use it in GitHub Desktop.
Save btechmag/4d89a72c424126c3306b10a43bc49387 to your computer and use it in GitHub Desktop.
C Program to find and print the square of each one of the even values from 1 to a specified value.
#include<stdio.h>
int main()
{
//Program to find and print the square of each one of the even values from 1 to a specified value
int x, i;
printf("Input an integer: ");
scanf("%d", &x);
printf("List of square of each one of the even values from 1 to %d : \n", x);
for(i = 2; i <= x; i++)
{
if((i % 2) == 0)
{
printf("%d^2 = %d\n", i, i * i);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment