A PHP Error was encountered

Severity: Warning

Message: A non-numeric value encountered

Filename: controllers/home.php

Line Number: 222

A PHP Error was encountered

Severity: Warning

Message: A non-numeric value encountered

Filename: controllers/home.php

Line Number: 228

Command Line Arguments - C Programming Questions and Answers
Home / C Programming / Command Line Arguments :: Find Output of Program

C Programming :: Command Line Arguments

  1. What will be the output of the program (myprog.c) given below if it is executed from the command line?
    cmd> myprog one two three

     /* myprog.c */
     #include
    
      int main(int argc, char **argv) 
      {   
         printf("%c\n", **++argv);         
         return 0;
      } 
    

  2. A.

    myprog one two three

    B.

    myprog one

    C.

    o

    D.

    two

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What will be the output of the program (myprog.c) given below if it is executed from the command line?
    cmd> myprog one two three

    /* myprog.c */
     #include 
     #include 
    
     int main(int argc, char **argv) 
     {  
        printf("%s\n", *++argv);     
        return 0;
     } 
    

  4. A.

    myprog

    B.

    one

    C.

    two

    D.

    three

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What will be the output of the program (sample.c) given below if it is executed from the command line (Turbo C in DOS)?
    cmd> sample 1 2 3

     /* sample.c */
     #include 
    
     int main(int argc, char *argv[]) 
     {   
         int j;  
         j = argv[1] + argv[2] + argv[3];       
         printf("%d", j);  
         return 0; 
    } 
    

  6. A.

    6

    B.

    sample 6

    C.

    Error

    D.

    Garbage value

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What will be the output of the program (sample.c) given below if it is executed from the command line (turbo c under DOS)?
    cmd> sample Good Morning

     /* sample.c */
     #include 
    
     int main(int argc, char *argv[]) 
     {  
        printf("%d %s", argc, argv[1]);           
        return 0; 
     } 

     

  8. A.

    3 Good

    B.

    2 Good

    C.

    Good Morning

    D.

    3 Morning

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What will be the output of the program

    #include
     void fun(int);  
    
     int main(int argc)
     {    
         printf("%d ", argc);       
         fun(argc); 
         return 0; 
    } 
    void fun(int i) 
     {    
        if(i!=4)      
            main(++i);
     } 
    

  10. A.

    1 2 3

    B.

    1 2 3 4

    C.

    2 3 4

    D.

    1

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will be the output of the program (sample.c) given below if it is executed from the command line?
    cmd> sample friday tuesday sunday

    /* sample.c */
     #include 
    
     int main(int argc, char *argv[]) 
     {   
         printf("%c", **++argv);     
         return 0;
     } 
    

  12. A.

    s

    B.

    f

    C.

    sample

    D.

    friday

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What will be the output of the program (myprog.c) given below if it is executed from the command line?
    cmd> myprog friday tuesday sunday

    /* myprog.c */
     #include 
    
     int main(int argc, char *argv[]) 
     {  
        printf("%c", *++argv[1]);     
        return 0;
     } 
    

  14. A.

    r

    B.

    f

    C.

    m

    D.

    y

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What will be the output of the program (sample.c) given below if it is executed from the command line?
    cmd> sample one two three

    /* sample.c */
     #include 
    
     int main(int argc, char *argv[]) 
     {   
          int i=0; 
          i+=strlen(argv[1]);       
          while(i>0)  
          {     
            printf("%c", argv[1][--i]);       
          }  
          return 0;
     } 
    

  16. A.

    three two one

    B.

    owt

    C.

    eno

    D.

    eerht

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What will be the output of the program in Turbo C?

     #include
    
      int main(int argc, char *argv, char *env[]) 
      {   
          int i;  
          for(i=1; i"%s\n", env[i]);     
        return 0; 
    } 
    

     

  18. A.

    List of all environment variables

    B.

    List of all command-line arguments

    C.

    count of command-line arguments

    D.

    Error: cannot have more than two arguments in main()

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What will be the output of the program (sample.c) given below if it is executed from the command line?
    cmd> sample Jan Feb Mar

    /* sample.c */
     #include
     #include  
    
     int main(int arc, char *arv[])
     {   
        int i;   
        for(i=1; i<_argc i printf class="string">"%s ", _argv[i]);
        return 0;
     } 
    

  20. A.

    No output

    B.

    sample Jan Feb Mar

    C.

    Jan Feb Mar

    D.

    Error

    View Answer

    Workspace

    Discuss Discuss in Forum