Pointers
- 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
- 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()
{
char *ch = "Interview Mania\n";
ch[9] = '.';
printf("%s\n", ch);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Segmentation fault
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
char *s = "Interview Mania";
char strArray[] = "Interview Mania";
printf("%d %d\n", sizeof(s), sizeof(strArray));
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
8 16
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
char s[] = "Interveiw Mania";
s[9] = '.';
printf("%s\n", s);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Interveiw.Mania