Pointers
- What type of initialization is needed for the segment “p[3] = ‘3’;” to work?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
char p[] = “Interview!”;
- Comment on the output of the following C code.
#include <stdio.h>
int main()
{
char *s = "Interveiw" //Line 1
char *p = "Mania\n"; //Line 2
s = p; //Line 3
printf("%s, %s\n", s, p); //Line 4
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Memory holding “this” loses its reference at line 3
- 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()
{
char *String = "Interveiw Mania";
char StringArray[] = "Interveiw Mania";
printf("%d %d\n", strlen(String), strlen(StringArray));
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
15 15