/*Write a C program to find
and print the square of
each one of the even values
from 1 to a specified value.
Test Data :
List of square of each one
of the even values from 1
to a 4 :
Expected Output:
2^2 = 4
4^2 = 16
*/
#include <stdio.h>
int main()
{
int i, result=1;
printf("List of square of\
\nof the even values from\
1 to a 4: ");
for(i=1;i<5;i++)
{
if(i%2==0)
{
result=i*i;
printf("\n\n%d^%d=%d"
,i,i,result);
}
}
getchar();
}
No comments:
Post a Comment