Log In Register

Units


Character Pointers And Functions - Questions and Answers

 

Practice these Character Pointers And Functions under C Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on Character Pointers And Functions for following purpose.


– Anyone who is wishing to increase their perfect knowledge of Character Pointers And Functions of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically Character Pointers And Functions.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on Character Pointers And Functions under C Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  Character Pointers And Functions topic of C Programming:

 

1.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char *str = "hello, world\n";
  5.         char *strc = "good morning\n";
  6.         strcpy(strc, str);
  7.         printf("%s\n", strc);
  8.         return 0;
  9.     }

Answer: Option C

Explanation:

2.

Comment on the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char *str = "This" //Line 1
  5.         char *ptr = "Program\n"; //Line 2
  6.         str = ptr; //Line 3
  7.         printf("%s, %s\n", str, ptr); //Line 4
  8.     }

Answer: Option C

Explanation:

3.

Comment on the output of this C code?

  1.     #include <stdio.h>
  2.     int add(int a, int b)
  3.     {
  4.         return a + b;
  5.     }
  6.     int main()
  7.     {
  8.         int (*fn_ptr)(int, int);
  9.         fn_ptr = add;
  10.         printf("The sum of two numbers is: %d", (int)fn_ptr(2, 3));
  11.     }

Answer: Option A

Explanation:

4.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char *str = "hello world";
  5.         char strary[] = "hello world";
  6.         printf("%d %d\n", strlen(str), strlen(strary));
  7.         return 0;
  8.     }

Answer: Option D

Explanation:

5.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char *str = "hello, world\n";
  5.         str[5] = '.';
  6.         printf("%s\n", str);
  7.         return 0;
  8.     }

Answer: Option A

Explanation:

6.

The syntax for constant pointer to address (i.e., fixed pointer address) is:

Answer: Option D

Explanation:

7.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char *str = "hello, world!!\n";
  5.         char strc[] = "good morning\n";
  6.         strcpy(strc, str);
  7.         printf("%s\n", strc);
  8.         return 0;
  9.     }

Answer: Option B

Explanation:

8.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void f(char *k)
  3.     {
  4.         k++;
  5.         k[2] = 'm';
  6.     }
  7.     void main()
  8.     {
  9.         char s[] = "hello";
  10.         f(s);
  11.         printf("%c\n", *s);
  12.     }

Answer: Option D

Explanation:

9.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char str[] = "hello, world";
  5.         str[5] = '.';
  6.         printf("%s\n", str);
  7.         return 0;
  8.     }

Answer: Option D

Explanation:

10.

Calling a function f with a an array variable a[3] where a is an array, is equivalent to

Answer: Option A

Explanation:

11.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void fun(char *k)
  3.     {
  4.         printf("%s", k);
  5.     }
  6.     void main()
  7.     {
  8.         char s[] = "hello";
  9.         fun(s);
  10.     }

Answer: Option D

Explanation:

12.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char *str = "hello world";
  5.         char strary[] = "hello world";
  6.         printf("%d %d\n", sizeof(str), sizeof(strary));
  7.         return 0;
  8.     }

Answer: Option B

Explanation:

13.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         char s[] = "hello";
  5.         s++;
  6.         printf("%c\n", *s);
  7.     }

Answer: Option D

Explanation:

14.

The correct way to declare and assign a function pointer is done by:
    (Assuming the function to be assigned is “int multi(int, int);”)

Answer: Option D

Explanation:

15.

What type initialization is needed for the segment “ptr[3] = ‘3’;” to work?

Answer: Option C

Explanation: