logo

CuriousTab

CuriousTab

Discussion


Home C Programming Pointers See What Others Are Saying!
  • Question
  • What will be the output of the program?
    #include<stdio.h>
    #include<string.h>
    
    int main()
    {
        int i, n;
        char *x="Alice";
        n = strlen(x);
        *x = x[n];
        for(i=0; i<=n; i++)
        {
            printf("%s ", x);
            x++;
        }
        printf("\n", x);
        return 0;
    }
    


  • Options
  • A. Alice
  • B. ecilA
  • C. Alice lice ice ce e
  • D. lice ice ce e

  • Correct Answer
  • lice ice ce e 

    Explanation
    If you compile and execute this program in windows platform with Turbo C, it will give "lice ice ce e".

    It may give different output in other platforms (depends upon compiler and machine). The online C compiler given in this site will give the Option C as output (it runs on Linux platform).


    More questions

    • 1. It is necessary to call the macro va_end if va_start is called in the function.

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 2. Left shifting a number by 1 is always equivalent to multiplying it by 2.

    • Options
    • A. True
    • B. False
    • Discuss
    • 3. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          printf("%%%%\n");
          return 0;
      }
      

    • Options
    • A. %%%%%
    • B. %%
    • C. No output
    • D. Error
    • Discuss
    • 4. A function that receives variable number of arguments should use va_arg() to extract arguments from the variable argument list.

    • Options
    • A. True
    • B. False
    • Discuss
    • 5. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          float a = 0.7;
          if(0.7 > a)
              printf("Hi\n");
          else
              printf("Hello\n");
          return 0;
      }
      

    • Options
    • A. Hi
    • B. Hello
    • C. Hi Hello
    • D. None of above
    • Discuss
    • 6. 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<stdio.h>
      
      int main(int sizeofargv, char *argv[])
      {
          while(sizeofargv)
              printf("%s", argv[--sizeofargv]);
          return 0;
      }
      

    • Options
    • A. sample friday tuesday sunday
    • B. sample friday tuesday
    • C. sunday tuesday friday sample
    • D. sunday tuesday friday
    • Discuss
    • 7. 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<stdio.h>
      
      int main(int argc, char *argv[])
      {
          printf("%c", *++argv[2] );
          return 0;
      }
      

    • Options
    • A. s
    • B. f
    • C. u
    • D. r
    • Discuss
    • 8. Point out the error in the program.
      #include<stdio.h>
      
      int main()
      {
          const int k=7;
          int *const q=&k;
          printf("%d", *q);
          return 0;
      }
      

    • Options
    • A. Error: RValue required
    • B. Error: Lvalue required
    • C. Error: cannot convert from 'const int *' to 'int *const'
    • D. No error
    • Discuss
    • 9. Bit fields CANNOT be used in union.

    • Options
    • A. True
    • B. False
    • Discuss
    • 10. What will be the output of the program (myprog.c) given below if it is executed from the command line?
      cmd> myprog 10 20 30
      /* myprog.c */
      #include<stdio.h>
      
      int main(int argc, char **argv)
      {
          int i;
          for(i=0; i<argc; i++)
              printf("%s\n", argv[i]);
          return 0;
      }
      

    • Options
    • A. 10 20 30
    • B. myprog 10 20
    • C. myprog 10 20 30
    • D. 10 20
    • Discuss


    Comments

    There are no comments.

Enter a new Comment