Answer to Question #201418 in C for Lucy

Question #201418

Write a C Program that does the following:

1. Declares a C-String called ‘m1’ and initializes it with the text “Programming is great fun!”.

2. Uses C-function puts() to print this string.

3. Asks the user to enter a string named ‘m2’ (Hint: Use gets() function for this.)

4. Concatenates the two strings and stores the result in ‘m3’.

For example, if the user enters m2 as “Not Really!”, m3 should be “Programming is great fun! Not really!”

5. Inserts the user entered array (m2) into m1 after “Programming is ...”

For the above example, the resultant String would become “Programming is Not really! great fun!”


1
Expert's answer
2021-06-01T03:01:12-0400
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int main()
{
    char m1[]={"Programming is great fun "};
    puts(m1);
    char m2[50];
    printf("\nEnter another string : ");
    gets(m2);
    strcat(m1,m2);
    char m3[]="";
    strcat(m3,m1);
    printf("Concatenated string : ");
    puts(m3);
    printf("User entered string in original string : ");
    puts(m1);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS