Online Test

:

 

What is the output of the following program?

#include<stdio.h>
int main()
{
  char str[2];
  printf("\nEnter the string : ");
  gets(str);
  printf("%s\t%s",str,(str+5));
}
//Input:
//Enter the string : Hi Tech Epi

Point out the error in the program

#include<stdio.h>
int main()
{
    int a=10;
    void f();
    a = f();
    printf("%d\n", a);
    return 0;
}
void f()
{
    printf("Hi");
}

Which of the following statements correct about the below program?

#include<stdio.h>

int main()
{
    struct emp
    {
        char name[25];
        int age;
        float sal;
    };
    struct emp e[2];
    int i=0;
    for(i=0; i<2; i++)
        scanf("%s %d %f", e[i].name, &e[i].age, &e[i].sal);

    for(i=0; i<2; i++)
        scanf("%s %d %f", e[i].name, e[i].age, e[i].sal);
    return 0;
}

 If the file name is enclosed in angle brackets


Find the output of below programs.

A. #include<stdio.h>
    int main()
    {
      printf("%d\n",x);
      return 0;
    }
    int x;
  B. #include<stdio.h>
      int main()
     {
       extern int x;
       printf("%d\n",x);
       return 0;
     }
     int x;

If the binary eauivalent of 5.375 in normalised form is 0100 0000 1010 1100 0000 0000 0000 0000, what will be the output of the program (on intel machine)?

#include<stdio.h>
#include<math.h>
int main()
{
    float a=5.375;
    char *p;
    int i;
    p = (char*)&a;
    for(i=0; i<=3; i++)
        printf("%02x\n", (unsigned char)p[i]);
    return 0;
}

Which of the following statements are correct about an array?

1: The array int num[26]; can store 26 elements.
2: The expression num[1] designates the very first element in the array.
3: It is necessary to initialize the array at the time of declaration.
4: The declaration num[SIZE] is allowed if SIZE is a macro.

Which program is correct?

/*Program 1*/
#include<stdio.h>
int main()
{
  int  a[2][3]={1,2,3,4,5,6};
  int (*ptr)[3]=a; //Line 5
  printf("%d,%d",a[1][2],*(*(ptr+1)+2));
}
/*Program 2*/
#include<stdio.h>
int main()
{
  int  a[2][3]={1,2,3,4,5,6};
  int **ptr=a;   //Line 5
  printf("%d,%d",a[1][2],*(*(ptr+1)+2));
}

The below two lines are equivalent to
#define C_IO_HEADER 
#include C_IO_HEADER


Point out the error in the program

#include<stdio.h>
#define SI(p, n, r) float si; si=p*n*r/100;
int main()
{
    float p=2500, r=3.5;
    int n=3;
    SI(p, n, r);
    SI(1500, 2, 2.5);
    return 0;
}

Point out the error in the following program.

#include<stdio.h>
#include<stdlib.h>
int main()
{
    char *ptr;
    *ptr = (char)malloc(30);
    strcpy(ptr, "RAM");
    printf("%s", ptr);
    free(ptr);
    return 0;
}

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;
}

Which of the following statements correct about the below code?
maruti.engine.bolts=25;


What will be the output of the program?

#include<stdio.h>
void fun(int);
typedef int (*pf) (int, int);
int proc(pf, int, int);
int main()
{
    int a=3;
    fun(a);
    return 0;
}
void fun(int n)
{
    if(n > 0)
    {
        fun(--n);
        printf("%d,", n);
        fun(--n);
    }
}

 


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("TechEpi");
}

What will be the output of the program?

#include<stdio.h>
void fun(int*, int*);
int main()
{
    int i=5, j=2;
    fun(&i, &j);
    printf("%d, %d", i, j);
    return 0;
}
void fun(int *i, int *j)
{
    *i = *i**i;
    *j = *j**j;
}

What will be the output of the program?
#include<stdio.h>
#include<math.h>
int main()
{
    printf("%f\n", sqrt(36.0));
    return 0;
}


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<stdio.h>
#include<dos.h>
int main(int arc, char *arv[])
{
    int i;
    for(i=1; i<_argc; i++)
        printf("%s ", _argv[i]);
    return 0;
}

Which of the following function is more appropriate for reading in a multi-word string?


Each printf statement prints 2 addresses. Select the line in which 2 addresses are same.

#include<stdio.h>
int main()
{
  int a[6]={1,2,3,4,5,6};
  printf("%ul,%ul,",a,&a);   //Line 1
  printf("%ul,%ul,",a+1,&a+1); //Line 2 
  printf("%ul,%ul",a+6,&a+1);//Line 3
}

String operation such as strcat(s, t), strcmp(s, t), strcpy(s, t) and strlen(s) heavily     rely upon.


Comment on the following declaration?
    int (*ptr)(); // i)
    char *ptr[]; // ii)


Which of the following range is a valid long double (Turbo C in 16 bit DOS OS) ?

 


Point out the error in the following program.

#include<stdio.h>
#include<stdlib.h>
int main()
{
    static char *p = (char *)malloc(10);
    return 0;
}

Which of the following statements correct about the below program?

#include<stdio.h>

int main()
{
    union a
    {
        int i;
        char ch[2];
    };
    union a u1 = {512};
    union a u2 = {0, 2};
    return 0;
}
1: u2 CANNOT be initialized as shown.
2: u1 can be initialized as shown.
3: To initialize char ch[] of u2 '.' operator should be used.
4: The code causes an error 'Declaration syntax error'
 

About Us

TechEpi.com is an online learning website.We cover the latest tech news,online tutorials,blog,online test for Aptitude,C,Java,PHP to improve your knowledge.

Newsletter


Follow TechEpi on