To Check whether a year is Leap or Not

#include <stdio.h>

int main(int argc, char * argv[]) {

   int year;
   if(argc!=2)
   {
       printf("\nArgument not in Correct Format\n");
       exit(0);
   }
   year=atoi(argv[1]);
   if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))
      printf("\n%d is a leap year\n", year);
   else
      printf("\n%d is not a leap year\n", year);

   return 0;

}


Output: 



Post a Comment

4 Comments

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. I didn't understand what u want to say. But if u r looking for complete question then try https://simpleway2code.blogspot.in/2017/10/tcs-placement-paper-question.html

      Delete
  2. please upload more mcq questions based on c

    ReplyDelete
  3. you are very knowledgable man this website is of great help for us tcs aspirants thank you!

    ReplyDelete