Array and Strings – Strings – Problem #7

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: easy

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.

Back to Lab Problems
Array and Strings/Strings/Problem #7

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #7

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.