Explanation along with solution will be appreciated. Consider the following code
ID: 3812366 • Letter: E
Question
Explanation along with solution will be appreciated.
Consider the following code. char str[20]; int x, y; scanf ("%d%s%d'', &x;, str, &y;); What will values of x, y and str be the user types the following: 100dogs and 1200 dogs and 2 What is the value of movie after each statement (lines 2-5) char movie[100]; strcpy (movie, "Beauty and The Beast"); movie [4] = ''; strcpy(movie + 4, "I"); strcat(movie, "-Disney"); Write statements for the following. Make sure to declare any variables needed. a. Read a string from the standard input (at most 50 characters) b. Create a new string by duplicating the first string (for example if string 1 is knock, string 2 becomes knock) c. Print the second string to standard output Consider the following function: void changeit(char *value) {char*p; for (p = value; *p l = '', p++) *p = --(*p); puts (value);} What is the output of changeit("Monday")? Consider the following string: char Oscar Wilde [200] = "I can resist everything except temptation"; Write a statement to print the substring starting at everything Write a statement so the string ends at everythingExplanation / Answer
1. x = 100, str = dogsand1, y = 200, as in the starting until we get the character it will be taken as number thus 100 goes in x, then until we type space it will go in str, thus str = dogsand1 , after we type space, untill we type character it will go in Y as number thus Y = 200.
2. 2 -> "Beauty and the Beast" // as copied by strcpy
3 -> "Beau" as after that it will be terminated by ''
4-> "Beau!" as "!" will be copied at 4th index onwards.
5-> "- Disney" as copied by strcpy.
3. a.) char str[51] ; scanf("%s",str);
b.) char s1[100],s2[100];
strcpy(s2,s1);
strcat(s2,s1);
c.) printf("%s ",s2);
4. "Lnmc`x" as every character will shift to character with one lesser ascii value.
5. printf("%.*s", 28, oscarWilde + 13); it wil print the string from 13th index till last, which is of length 28.
oscarWilde[23] = ''; this will end the string just after everything is printed.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.