Monday, 20 February 2017

IO 28

QUESTION DESCRIPTION :


Write a program to print the sum of even numbers between 1 and 200

Input and Output Format:

Refer sample input and output for formatting specification.

All float values are displayed correct to 2 decimal places.

All text in bold corresponds to input and the rest corresponds to output.


TEST CASE 1


INPUT

0

OUTPUT

10100


EXPLANATION :

The program requires you to print the sum of first 200 numbers starting from 1. That can either be done using a simple for or while loop ( For Loop Concepts , While Loop Concepts)


ALGORITHM :

  • Take a loop from 0 to 200.
  • Take a variable ( sum ) and add loop variable ( i ) to it , to calculate the sum.
  • Increase the loop variable by 2 instead of 1 ( i=i+2 )
  • Print the calculated sum.

SOLUTION : (Please use this as reference only)


CODE

No comments:

Post a Comment