Pointers
- What will be the output of the following C code?
#include <stdio.h>
void function(char *p)
{
printf("%s", p);
}
void main()
{
char str[] = "Interveiw Mania";
function(str);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Interveiw Mania
- What will be the output of the following C code?
#include <stdio.h>
void fun(char *p)
{
p++;
p[3] = 'N';
printf("%c\n", *p);
}
void main()
{
char s[] = "WELCOME";
fun(s);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
E
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int array[3] = {16, 17, 18};
int *p = &array[1];
float m = 1;
p = p + m;
printf("%d\n", *p);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Compilation Error
main.c: In function ‘main’:
main.c:7:15: error: invalid operands to binary + (have ‘int *’ and ‘float’)
p = p + m;
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
char *str = "Interview, Mania\n";
char *strc = "Welcome to\n";
strcpy(strc, str);
printf("%s\n", strc);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Crash/segmentation fault
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int arr[5] = {61, 62, 63, 64, 65};
void *p = &arr[1];
void *p1 = &arr[5];
int Res = 0;
Res = p1 - p;
printf("%d\n", Res);
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
16