Array and Strings – Strings – Problem #7
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Declare a C string and initialize it as follows : "Your_Roll Number, Your First Name, Your Last Name" For example, if your roll number is 20CS10021. Your first name is Rohit and your last name is Raj, then the C string will be *20CS10021,Rohit Raj". Initialize this string statically in your code; you do not take an input from the user. Now, write a C program to produce the following string in the output, from the above string. "My name is Rohit Raj. My roll number is 20C510021", To do this, your code should have a printf statement as follows : printf("My name is %s %s. My roll number is %s", str1, str2, str3) Your C code should populate these three strings from the original string by extracting the relevant substrings. Marks will not be given if you hardcode the output statement.