Top

Pointers

1.

Which of the following changes can correct the program so that it prints “Geeks Quiz”?

#include  
  
void myStrcat(char *a, char *b) 
{ 
    int m = strlen(a); 
    int n = strlen(b); 
    int i; 
    for (i = 0; i <= n; i++) 
       a[m+i]  = b[i]; 
} 
  
int main() 
{ 
    char *str1 = "Geeks "; 
    char *str2 = "Quiz"; 
    myStrcat(str1, str2); 
    printf("%s ", str1); 
    return 0; 
} 

 

Answer: A

No answer description available for this question.
 

Enter details here

Answer: B

No answer description available for this question.
 

Enter details here

3.

Which of the following declaration throw run-time error?

Answer: D

No answer description available for this question.
 

Enter details here

4.

What substitution should be made to //-Ref such that ptr1 points to variable C?

int main()
{
int a = 1, b = 2, c = 3;
int *ptr1 = &a;
int **sptr = &ptr1;
//-Ref
}

 

Answer: A

No answer description available for this question.
 

Enter details here

5.

What is the output of this C code?

void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int **r = &p;
printf("%p %p", *r, a);
}

 

Answer: C

No answer description available for this question.
 

Enter details here

Loading…