Pointers
- What will be the output of the following C code?
#include <stdio.h>
void count(char *ptr)
{
ptr++;
ptr[3] = 'S';
}
void main()
{
char str[] = "AJIT";
count(str);
printf("%c\n", *str);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
A
- Calling a function fun with num an array variable num[3] where num is an array, is equivalent to __________.
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Option A, B and C is equivalent.
- What is the correct way to declare and assign a function pointer?
(Assuming the function to be assigned is "int multi(int, int);")
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
int (*fn_ptr)(int, int) = multi;
- What will be the output of the following C code?
#include <stdio.h>
int calc(int n, int m)
{
return n + m;
}
int main()
{
int (*calc_ptr)(int, int);
calc_ptr = calc;
printf("The Addition of two numbers is: %d", (int)calc_ptr(21, 13));
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
34
- What is the syntax for constant pointer to address (i.e., fixed pointer address)?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
<type> * const <name>