Nmit C - Aptitude Test

30 Questions | Total Attempts: 154

SettingsSettingsSettings
Please wait...
Nmit C - Aptitude Test

.


Questions and Answers
  • 1. 
    .What will be the output of the program?void main(){            int  const * p=5;            printf("%d",++(*p));}
    • A. 

      Compiler error

    • B. 

      9

    • C. 

      6

    • D. 

      5

  • 2. 
    What will be the output of the program?main(){            char s[ ]="man";            int i;            for(i=0;s[ i ];i++)            printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);}
    • A. 

      mmmm aaaa nnnn

    • B. 

      Mann

    • C. 

      Mman nnan

    • D. 

      Mmmm nnnn aaaa

  • 3. 
    What will be the output of the program?main(){            float food = 1.1;            double kick = 1.1;            if(food==kick)                  printf("I love food");            else                 printf("kick me");}
    • A. 

      Kick me

    • B. 

      I love food

    • C. 

      Compiler error

    • D. 

      None of the above

  • 4. 
    What will be the output of the program?main(){             int c[ ]={2.8,3.4,4,6.7,5};             int j,*p=c,*q=c;             for(j=0;j<5;j++)             {                        printf(" %d ",*c);                        ++q;              }            for(j=0;j<5;j++)             {                        printf(" %d ",*p);                        ++p;                  }}
    • A. 

      2222223465

    • B. 

      23465 22222

    • C. 

      234652222

    • D. 

      22222 23465

  • 5. 
    What will be the output of the program?#define square(x) x*xmain(){int i;i = 64/square(4);printf("%d",i);}
    • A. 

      64

    • B. 

      4

    • C. 

      32

    • D. 

      16

  • 6. 
    What will be the output of the program?main(){ printf("\nab"); printf("\bsi"); printf("\rha");}
    • A. 

      Hai

    • B. 

      Absiha

    • C. 

      Asiha

    • D. 

      Haabsi

  • 7. 
    Point out the error/warning in the program?#include<stdio.h> int main(){    unsigned char ch;    FILE *fp;    fp=fopen("trial", "r");    while((ch = getc(fp))!=EOF)        printf("%c", ch);    fclose(fp);    return 0;}
    • A. 

      Error: in unsigned char declaration

    • B. 

      Error: while statement

    • C. 

      No errorNo error

    • D. 

      It prints all characters in file "trial"

  • 8. 
    What will be the output of the program?struct point {   int x;   int y; };struct point origin,*pp;main(){  pp=&origin;  printf("origin is(%d%d)\n",(*pp).x,(*pp).y);  printf("origin is (%d%d)\n",pp->x,pp->y);} 
    • A. 

      Origin is(0,0) origin is(0,0)

    • B. 

      Origin is (1,1) origin is (1,1)

    • C. 

      Origin is(0,1) origin is(0,1)

    • D. 

      Compiler error

  • 9. 
    What does the following segment of code do?fprintf(fp, “Copying!”);
    • A. 

      It writes “Copying!” into the file pointed by fp

    • B. 

      It reads “Copying!” from the file and prints on display

    • C. 

      It writes as well as reads “Copying!” to and from the file and prints it

    • D. 

      None of the mentioned

  • 10. 
    What will be the output of the program?main(){int a=5,b=7;b=a++;a=a+++b++;printf("%d",a);}
    • A. 

      12

    • B. 

      13

    • C. 

      14

    • D. 

      15

  • 11. 
     What will be the output of the program?#includeint main(){    int i=3;    switch(i)    {        case 1:            printf("Hello\n");        case 2:            printf("Hi\n");        case 3:            continue;        default:            printf("Bye\n");    }    return 0;}
    • A. 

      A. Error: Misplaced continue A. Error: Misplaced continue Error: Misplaced continue

    • B. 

      Bye

    • C. 

      No output

    • D. 

      Hello Hi

  • 12. 
    What will be the output of the program? #include <stdio.h>    int main()   {        FILE *fp;        char c;        int n = 0;        fp = fopen("newfile1.txt", "r");        while (!feof(fp))        {            c = getc(fp);            putc(c, stdout);        }    }
    • A. 

      None of the mentioned

    • B. 

      Prints to the screen content of newfile1.txt completely

    • C. 

      Prints to the screen some contents of newfile1.txt

    • D. 

      Compilation error

  • 13. 
    What will be the output of the program if value 25 given to scanf()?#include<stdio.h> int main(){    int i;    printf("%d\n", scanf("%d", &i));    return 0;}
    • A. 

      1

    • B. 

      2

    • C. 

      5

    • D. 

      25

  • 14. 
    What will be the output of the program?#include<stdio.h>int main(){    int k, num=30;    k = (num>5 ? (num <=10 ? 100 : 200): 500);    printf("%d\n", num);    return 0;}
    • A. 

      30

    • B. 

      100

    • C. 

      200

    • D. 

      500

  • 15. 
    The library function used to find the last occurrence of a character in a string is
    • A. 

      Strrchr()

    • B. 

      Strnstr()

    • C. 

      Laststr()

    • D. 

      Strstr()

  • 16. 
    ) What will be the output of following program ? #include <stdio.h> int main() {   static char a;   static long b;   int c;   printf("%d,%d,%d",a,b,c);   return 0;}
    • A. 

      Garbage,Garbage,Garbage

    • B. 

      0,0,0

    • C. 

      Garbage,Garbage,0

    • D. 

      0,0,Gargabe

  • 17. 
    What will be the output of the program ?#include<stdio.h> int main(){    char str[] = "Nagpur";    str[0]='K';    printf("%s, ", str);    str = "Kanpur";    printf("%s", str+1);    return 0;}
    • A. 

      Error

    • B. 

      Kagpur, Kanpur

    • C. 

      Nagpur, Kanpur

    • D. 

      Kagpur, anpur

  • 18. 
    Point out the correct statements are correct about the program below?#include<stdio.h>int main(){    char ch;    while(x=0;x<=255;x++)        printf("ASCII value of %d character %c\n", x, x);    return 0;}
    • A. 

      Error: while statement missing

    • B. 

      Error: x undeclared identifier

    • C. 

      The code prints all ASCII values and its characters

    • D. 

      The code generates an infinite loop

  • 19. 
    What will be the output of following program ? #include int main(){   int ok=-100;   -100;   printf("%d",ok);   return 0;}
    • A. 

      100

    • B. 

      Error

    • C. 

      -100

    • D. 

      0

  • 20. 
    What will be the output of the program ?#include<stdio.h> int main(){    float arr[] = {12.4, 2.3, 4.5, 6.7};    printf("%d\n", sizeof(arr)/sizeof(arr[0]));    return 0;}
    • A. 

      4

    • B. 

      5

    • C. 

      6

    • D. 

      7

  • 21. 
    #include <stdio.h>enum numbers{   zero, one, two, three , four=3,five,six,seven=0,eight};void main(){     printf("%d,%d,%d,%d,%d,%d,%d,%d,%d",zero,one,two,three,four,five,six,seven,eight);}
    • A. 

      0,1,2,3,3,4,5,0,1

    • B. 

      0,1,2,4,5,6,7,8,9

    • C. 

      0,1,2,3,3,1,2,3,4

    • D. 

      0,1,2,3,3,4,5,0,9

  • 22. 
    Point out the correct statement which correctly free the memory pointed to by 's' and 'p' in the following program?#include<stdio.h>#include<stdlib.h> int main(){    struct ex    {        int i;        float j;        char *s    };    struct ex *p;    p = (struct ex *)malloc(sizeof(struct ex));    p->s = (char*)malloc(20);    return 0;}
    • A. 

      Free(p->s); , free(p);

    • B. 

      Free(p); , free(p->s);

    • C. 

      Free(p->s);

    • D. 

      Free(p);

  • 23. 
    What do the following declaration signify?void *cmp();
    • A. 

      Cmp is a function that return a void pointer.

    • B. 

      Cmp is a pointer to an void type.

    • C. 

      Cmp is a void type pointer variable.

    • D. 

      Cmp function returns nothing.

  • 24. 
    What will be the output of following program ?#include <stdio.h>int main(){int var=250;printf("value of var = %d\n",var);200+50;"nmit";printf("%s\n","mygurkul");return 0;}
    • A. 

      Value of var = 250 nmit

    • B. 

      Value of var = 250 mygurkul

    • C. 

      ERROR

    • D. 

      Value of var = 250 Garbage

  • 25. 
    Point out the error in the following program.#include<stdio.h>void display(int (*ff)()); int main(){    int show();    int (*f)();    f = show;    display(f);    return 0;}void display(int (*ff)()){    (*ff)();}int show(){    printf("IndiaBIX");}
    • A. 

      No error and prints "IndiaBIX"

    • B. 

      Error: invalid parameter in function display()

    • C. 

      Error: invalid function call f=show;

    • D. 

      No error and prints nothing.

Back to Top Back to top