Problem:-
This challenge will help you to learn how to take a character, a string and a sentence as input in C.
To take a single character as input, you can use scanf("%c", &ch );
and printf("%c", ch)
writes a character specified by the argument char to stdout
char ch;
scanf("%c", &ch);
printf("%c", ch);
This piece of code prints the character .
You can take a string as input in C using scanf(“%s”, s)
. But, it accepts string only until it finds the first space.
In order to take a line as input, you can use scanf("%[^\n]%*c", s);
where is defined as char s[MAX_LEN]
where is the maximum size of . Here, []
is the scanset character. ^\n
stands for taking input until a newline isn't encountered. Then, with this %*c
, it reads the newline character and here, the used *
indicates that this newline character is discarded.
Note: The statement: scanf("%[^\n]%*c", s);
will not work because the last statement will read a newline character, \n
, from the previous line. This can be handled in a variety of ways. One way is to use scanf("\n");
before the last statement.
Task
You have to print the character, , in the first line. Then print in next line. In the last line print the sentence, .
Input Format
First, take a character, as input.
Then take the string, as input.
Lastly, take the sentence as input.
Constraints
Strings for and will have fewer than 100 characters, including the newline.
Output Format
Print three lines of output. The first line prints the character, .
The second line prints the string, .
The third line prints the sentence, .
Sample Input 0
C
Language
Welcome To C!!
Sample Output 0
C
Language
Welcome To C!!
Solution:-
Recommended post:-
- Very Cool numbers | Hacker earth solution
- Birthday party | Hacker earth solution
- Most frequent | hacker earth problem solution
- program to find symetric difference of two sets
- cost of balloons | Hacker earth problem solution
- Chacha o chacha | hacker earth problem solution
- jadu and dna | hacker earth solution
- Bricks game | hacker earth problem
- Anti-Palindrome strings | hacker earth solution
- connected components in the graph | hacker earth data structure
- odd one out || hacker earth problem solution
- Minimum addition | Hackerearth Practice problem
- The magical mountain | Hackerearth Practice problem
- The first overtake | Hackerearth Practice problem
Data structure:-
- Program to find cycle in the graph
- Implementation of singly link list
- Implementation of queue by using link list
- Algorithm of quick sort
- stack by using link list
- program to find preorder post order and inorder of the binary search tree
- Minimum weight of spanning tree
- Preorder, inorder and post order traversal of the tree
Key points:-
- How to set limit in the floating value in python
- What is boolean data type
- How to print any character without using format specifier
0 Comments