Take FREE!! Online AMCAT Mock Test to Crack Wipro NLTH, Capgemini, etc.
Get Off-Campus Placement Jobs Info !!!
Practice Given Here Wipro NLTH Practice Q&A

Program Discussion :: Basics

Home > Programs > Basics

313 / 259

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: