Q. How do you convert this char array to string?
Code:char str[]={'g','l','o','b','y'};
Dear candidates you will find MCQ questions of C Programming here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question
char str[]={'g','l','o','b','y'};
int main()
{
int str[]={'g','l','o','b','y'};
printf("A%c ",str);
printf("A%s ",str);
printf("A%c ",str[0]);
return 0;
}
int main()
{
char str[]={"C","A","T","\0"};
printf("%s",str);
return 0;
}
int main()
{
char str1[]="JOHN";
char str2[20];
str2= str1;
printf("%s",str2);
return 0;
}
int main()
{
char str[25];
scanf("%s", str);
printf("%s",str);
return 0;
}
//input: South Africa
int main()
{
char str[2];
scanf("%s", str);
printf("%s",str);
return 0;
}
//Input: South
int main()
{
char str[2];
int i=0;
scanf("%s", str);
while(str[i] != '\0')
{
printf("%c", str[i]);
i++;
}
return 0;
}
//Input: KLMN
int main()
{
char country[]="BRAZIL";
char *ptr;
ptr=country;
while(*ptr != '\0')
{
printf("%c", *ptr);
ptr++;
}
return 0;
}
int main()
{
char *p1 = "GOAT";
char *p2;
p2 = p1;
printf("%s", p2);
}
int main()
{
char *p1 = "GOAT";
char *p2;
p2 = p1;
p2="ANT";
printf("%s", p1);
}