Programming C : Print all even numbers among 1 and N in descending order, where N will through from keyboard.

Programming C : Print all even numbers among 1 and N in descending order, where N will through from keyboard.

Programming C

Problem : Print all even numbers among 1 and N in descending order, where N will through from keyboard.

/*
Author : Sabya Roy
*/

 

#include <stdio.h>
#include <stdlib.h>

main()
{
              int n,i, k=1;                                                //Taking variables
              printf(“Enter an integer number : “);  //Show the dialog to input N
              scanf(“%d”,&n);                                      //input the value of N
              for(i=n; i>0 ; i–)                                    //using condition of for loop
              {
                            if(i%2==0)                               //condition to get even number
                            {
                                          if (k==1)
                                          {
                                                        printf(“Even numbers of the series : %d”,i);  //Show the series
                                                        k++;
                                          }
                                          else
                                          printf(“%3d”,i);                                                                   //Show the series full
                            }
              }
              getch();
}

———————————————————————————————————————————————————-




Output :

Enter an integer number : 15
Even numbers of the series : 14  12  10  8  6  4  2

———————————————————————————————————————————————————-

Share this post

Comment (1)

  • Jaylene Reply

    i love pastry shoes they are so hot and unique coartngs to angela and vanessa for making the cutest shoes ever.my favorite hsoe out of all are the berry fab cookies they are so pretty because i love bluetalk later. popcorn

    June 13, 2017 at 9:16 am

Leave a Reply

Your email address will not be published. Required fields are marked *