Is there any difference between the two statements? char *ch = "ExamAdept"; char ch[] = "ExamAdept";
A:
Yes
B:
No
C:
D:
Answer:A
In first statement the character pointer ch stores the address of the string "ExamAdept". The second statement specifies the space for 7 characters be allocated and that the name of location is ch.
Discuss About this Question.
For the following statements will arr[3] and ptr[3] fetch the same character? char arr[] = "ExamAdept"; char *ptr = "ExamAdept";
A:
Yes
B:
No
C:
D:
Answer:A
Yes, both the statements prints the same character 'i'.
Discuss About this Question.
Will the program compile successfully?
#include<stdio.h>
int main()
{
char a[] = "India";
char *p = "BIX";
a = "BIX";
p = "India";
printf("%s %s\n", a, p);
return 0;
}
A:
Yes
B:
No
C:
D:
Answer:B
Because we can assign a new string to a pointer but not to an array a.
Discuss About this Question.
Ad Slot (Above Pagination)
Install ExamAdept
Fast access — add this app to your device.
To install on iPhone/iPad: tap Share → Add to Home Screen.
Discuss About this Question.