짝수 제곱수는 - 2 2 입니다. , 4 2 , 6 2 , 8 2 ,………
=4, 16, 36, 64, 100, ………
알고리즘
START Step 1: declare two variables a and n Step 2: read number n at runtime Step 3: use for loop to print square numbers For a=2; a*a<=n;a+=2 until the condition satisfy loop will continue and Print a*a STOP
프로그램 1
#include<stdio.h>
int main(){
int a,n;
printf("enter a number for n:");
scanf("%d",&n);
for(a=2;a*a<=n;a+=2) //print even squares that are present in between 1 and n{
printf("%d\n",a*a);
}
return 0;
} 출력
enter a number for n:200 4 16 36 64 100 144 196
프로그램 2
다음은 1에서 n −
사이의 짝수 큐브를 찾는 프로그램입니다.#include<stdio.h>
int main(){
int a,n;
printf("enter a number for n:");
scanf("%d",&n);
for(a=2;a*a*a<=n;a+=2){
printf("%d\n",a*a*a);
}
return 0;
} 출력
enter a number for n:300 8 64 216