Consider the following statements. What is the output if the user enters the und
ID: 3688023 • Letter: C
Question
Consider the following statements. What is the output if the user enters the underlined string: Consider the following array declarations. Add statements to: Read two strings from the user into x and y. Copy the one that comes first in lexicographical order into z. Print z to the standard output. What is the value of str 1 after each statement (lines 2-5) Consider the following string, write a statement to print the substring starting at never: char markTwainQ[200] = "I have never let my schooling interfere with my education";Explanation / Answer
1.
a=100,b=2,str=catsin1
2.
#include <stdio.h>
#include<string.h>
int main()
{
char x[25],y[25],z[25],cmp[50];
int i,j;
printf("enter");
gets(x);
gets(y);
strcat(z,x);
strcat(z,y);
for (i = 0;i < strlen(z);i++) //loop for sorting
{
for (j = i + 1;j <= strlen(z);j++)
{
if ((strcmp(z[i], z[j]) > 0))
{
strcpy(cmp, z[i]);
strcpy(z[i], z[j]);
strcpy(z[j], cmp);
}
}
}
printf("After sorting string is ");
for (i = 0;i <= strlen(z);i++)
{
printf("%s ", z[i]);
}
}
3.
The Force Awakens
The
The!
The! Again
4.
#include <stdio.h>
#include<string.h>
char* subString (const char* input, int offset, int len, char* dest)
{
int input_len = strlen (input);
if (offset + len > input_len)
{
return NULL;
}
strncpy (dest, input + offset, len);
printf("hi");
return dest;
}
int main()
{
int i;
char *str="i have never let my schooling interface with my education";
char *str1;
char *e;
//i=indexof("n");
e = strchr(str, 'e');
i = (int)(e - str);
printf("%d",i);
if( subString (str, i, strlen(str), str1))
{
printf ("%s ", str1);
}
return 0;
}