Predict Program Output Based on C String
Output of following C Programs are not very simple. These are simple but very interesting top c programs based on C Strings asked during viva and interviews.
Program-1
int main ()
{
char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'};
printf("Greeting message: %s\n", greeting );
return 0;
}
Program-2
int main()
{
char str[] = { 'A', 'B', 'C', 'D' };
char *p = &str[1];
*p++;
printf("%c ", *p);
*p++;
printf("%c ", *p);
}
Program-3
#include<string.h>
int main()
{
char str1[20] = "C Program";
char str2[20] = "C Practicals";
printf("%s\n", strcpy(strcat(str1, str2), str2));
return 0;
}
Program-4
#include<string.h>
int main()
{
printf("%d", strlen("01234567"));
return 0;
}
Program-5
int main()
{
printf(10 + "C Program Practicals");
return 0;
}
Click here to check ANSWER
No comments:
Post a Comment