URI / BEE CROWD 1073 - Even Square Solution in C,C++,Python | URI - BEECROWD - BEE 1073 Solution in C,C++,Python

URI / BEE CROWD 1073 - Even Square Solution in C,C++,Python | URI - BEECROWD - BEE 1073 Solution in C,C++,Python

                                                                                            beecrowd | 1073

Even Square

Adapted by Neilor Tonin, URI Brazil

                                                                                             Timelimit: 1


Read an integer N. Print the square of each one of the even values from 1 to including if it is the case.

Input

The input contains an integer (5 < < 2000).

Output

Print the square of each one of the even values from 1 to N, as the given example.

Be carefull! Some language automaticly print 1e+006 instead 1000000. Please configure your program to print the correct format setting the output precision.

Input SampleOutput Sample

6

2^2 = 4
4^2 = 16
6^2 = 36

URI / BEE CROWD 1073 - Even Square Solution in C,C++,Python | URI - BEECROWD - BEE 1073 Solution in C,C++,Python

                                         Demonstration:

Even numbers are those numbers that can be divided into two equal groups or pairs and are exactly divisible by 2.
Here we apply a range-based for loop which provides all the integers available in the input interval.
After this, a check condition for even numbers is applied to filter all the odd numbers and square the even number. 
Finally, print the result. 
N.B: Don't copy paste the code as same. Just try to understand it and try yourself.

  URI / BEE 1073 Solution in C :   

  URI / BEECROWD Online Judge 1073 Solve  in C :                                          

#include<stdio.h>
int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=2;i<=n;i+=2)
	{
	    printf("%d^2 = %d\n",i,i*i);
	}
	return 0;
}

 

0 Response to URI / BEE CROWD 1073 - Even Square Solution in C,C++,Python | URI - BEECROWD - BEE 1073 Solution in C,C++,Python

Post a Comment