Thursday, 26 October 2017

Command Line argument In Turbo C

How to run a program in Turbo C explained with the example

Program:


Step1: Type the program and save with the name “Even1.c”


#include<stdio.h>

int main(int argc, char *argv[])
{
    if(argc!=2)

       exit(1);


    if(atoi(argv[1])%2==0)


        printf("\nEVEN NUMBER\n");


return 0;

}






Step2: Compile the program by pressing F9





Then it will start linking





Step3: Go to the command prompt (OS shell) by selecting file – DOS/OS Shell





Step4: Pass command line arguments while executing the program







8 comments:

  1. I am not been able to run this program on turboc++

    ReplyDelete
  2. Are you following all steps correctly??

    ReplyDelete
  3. i am not been able to run this program i follow the above steps

    ReplyDelete
    Replies
    1. It's working. I have checked it lots of time but still if u are facing problem u cam also check in codeblocks. Its much more easier.

      Delete
    2. During tcs test where we are going to write the command line program and how we are going to execute that.

      Delete
  4. During TCS Test, You will have to write and execute Your program on TCS's own Compiler. In that compiler you have space to write your code and click on compile/execute. after that it will show you message like"your program has passed test cases".

    ReplyDelete
  5. when i execute this code in turbo c i'm not getting the output desired.if i enter 5 it displays as "illegal command 5".what can we do?

    ReplyDelete

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...