[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Program Discussion :: Basics

Home > Programs > Basics

313 / 279

Write a program using command line arguments to input a number and find that number is even or odd.

INPUT: 14
OUTPUT: Even


INPUT: 13
OUTPUT: Odd

Answer:

#include
int main(int argc,char *argv[])
{
    int i;
    if(argc==2)
    {
        if(atoi(argv[1])%2==0)
            printf("\nEVEN NO.\n");
        else
            printf("\nODD NO.\n");
     }
    else if(argc>2) 
        printf("\nEnter only one Integer..!!!\n");
    else 
        printf("\nEnter one Integer.!!!\n");
    return 0;


}

Asked In :: TCS

Post Your Answer Here:

Language:

Post Your Reply Here:



Language:

Post Your Reply Here: