Program Sum Of First N Even Natural Number

Sum of first N even natural number program in C
This is our first program in C programming language. This C program will print the text
“Hello World!” on the console output screen. In this post we will learn how to 
write a C Program and explore each statements in this C Program and many more.



  /*
      Program : Sum of N even natural  number
      Filename : sumEvenNo.c
      IDE Used To Developed : CodeBlocks
      Developed By : Pavito Golui
  */
  #include<stdio.h>
  int main()
   {
        int evensum=0, i=2, num, tovalue;

         printf("Enter value for N: ");
           scanf("%d",&num);
           tovalue=num*2;
         while(i<=tovalue);
         {
                if(i%2==0)
                     {
                         evensum=evensum+i;
                     }      
                  i++; 

         }      
         printf("Sum of  %d even No is %d: ",num,evensum);
          return(0);
  
 

Output :

  Enter value for N: 5
  Sum of 5 even No is: 30


Explanation Of Each Statements In The Program:-
To learn any programming language, practical is must important than others factors. First of
all we learn and understand the language and then we implements, each things related to 
the language and explore about it. After all we are interested in making products (Software)
by using that language.


Previous Post
Next Post
Related Posts