Program Sum Of First N Odd Natural Number

Program Sum Of First N Odd 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 odd natural  number
      Filename : sumOddNo.c
      IDE Used To Developed : CodeBlocks
      Developed By : Pavito Golui
  */
  #include<stdio.h>
  int main()
   {
        int oddsum=0, i=1, num, tovalue;

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

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

Output :

  Enter value for N: 3
  Sum of 5 odd No is: 9


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.


Program Sum Of First N Even Natural Number

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.


Program Of Factorial Of A Given Number

Program Of Factorial Of A Given Number

Factorial of a given 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 : factorial of a number
      Filename : factorial.c
      IDE Used To Developed : CodeBlocks
      Developed By : Pavito Golui
  */
  #include<stdio.h>
  int main()
   {
        int fact=1, i=1,num;

         printf("Enter a number : ");
           scanf("%d",&num);
         if(num==0);
        else
         {
             while(i<=num)
                { 
                   fact=fact*i;
                   i++;      
                 }

        }      
         printf("Factorial of %d is %d",num,fact);
          return(0);
  
 

Output :

  Enter a number: 5
  Factorial of 5 is 120 


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.


Program Product Of First N Natural Number

Program Product Of First N Natural Number

Product of first N natural numbers 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 First N Natural Numbers
      Filename : productNNaturalNum.c
      IDE Used To Developed : CodeBlocks
      Developed By : Pavito Golui
  */
  #include<stdio.h>
  int main()
   {
        int product=1,num,i=1;
         printf("Enter a value for N : ");
           scanf("%d",&num);
         while(i<=num)
           { 
                product=product*i;
                 i++;      
         
         printf("Product of N number is=%d",product);
          return(0);
  
 

Output :

  Enter a value for N :8
  Product of N Number is=40320 


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.


Program Sum Of First N Natural Numbers

Program Sum Of First N Natural Numbers

Sum of first N natural numbers 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 First N Natural Numbers
      Filename : sumNNaturalNum.c
      IDE Used To Developed : CodeBlocks
      Developed By : Pavito Golui
  */
  #include<stdio.h>
  int main()
   {
        int sum=0,num,i=1;
         printf("Enter a value for N : ");
           scanf("%d",&num);
         while(i<=num)
           { 
                sum=sum+i;
                 i++;      
         
         printf("Sum of N number is=%d",sum);
          return(0);
  
 

Output :

  Enter a value for N :10
  Sum of N Number is=55 


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.


Program Print N Even Natural Number By User Input

Program Print N Even Natural Number By User Input

Check whether  a  number is divisible by 5 or not 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 : Print N Even Natural Number
      Filename : evenNnumber.c
      IDE Used To Developed : CodeBlocks
      Developed By : Pavito Golui
  */
  #include<stdio.h>
  int main()
   {
        int num, i, count=0;
         printf("Enter a value for N : ");
           scanf("%d",&num);
         while(1)
           { 
                 if(i%2==0)
                  {
                       count++;
                         printf("%d \n",i);
                  } 
                    i++;
                if(count==num)
                  {
                     break;  
                   }
         
          return(0);
  
 

Output :

  Enter a value for N :15
    2
    4
    6
    8
    10
    12
    14
    16
    18
    20
    22
    24
    26
    28
    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.


Program To Check Whether  A Number Is Divisible By 5 or Not

Program To Check Whether A Number Is Divisible By 5 or Not

Check whether  a  number is divisible by 5 or not 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 : Check Number Divisible By 5 Or Not
      Filename : divisibleby5.c
      IDE Used To Developed : CodeBlocks
      Developed By : Pavito Golui
  */
  #include<stdio.h>
  int main()
   {
        int num;
         printf("Enter a number : ");
           scanf("%d",&num);
         if(year%5==0)
           {
                printf("%d is divisible by 5 \n",num);
           }
          else
           {
                printf("%d is not divisible by 5 \n",num); 
           } 
          return(0);
  
 

Output :

  Enter a number : 220
  220 is divisible by 5

  again run-:

  Enter a number :31
  31 is not divisible by 5



   




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.