Read different types of data from standard input, process them as shown in output format and print theanswer to standard output.Input format:First line contains integer N.Second line contains string S.Output formatFirst line should contain N x 2.Second line should contain the same string S.Constraints:0<N< 101<|S| < 15 where Slength of string s
Answers
In this issue, we have receive an integer, a double, and a String from stdin but output their elements in the manner indicated with in Surrender Arrangement segment. A piece of such program is provided in the editor to assist with the problem.
Intermediate Data Interpretation
1. With the first line, there is a digit.
2. This top quote has a duplication.
3. Inside the top stanza, there is a Sequence of characters.
Output Format
There will be following three output connections:
1. Print String: This is accompanied mostly by unaltered Cable that processes data on the first line.
2. Print Double: on the fourth row, followed by the unaltered twofold acquired in channel 0.
3. Publish Len, trailed by the recidivist communication's unmodified contents.
Answer:
#include <stdio.h>
int main(){
int num;
char str[14];
scanf("%d", &num);
scanf("%s", &str); // Reading input from STDIN
printf(" %d\n", num*2); // Writing output to STDOUT
printf("%s\n",str);
}
Explanation:
I have taken "num" in order to enter the interger values which is initialised under int and string with a limit of 14 in order to take the input of the string which is initialised under "char".In the next step I have taken the user input using scanf and I've used "%d" and "%s" for integer and string respectively. Since we require an output of the interger to be twice the value of the number given by the user, In the printf statement I have multiplied num with 2 and printed the string as it is to give us the desired ouput.
I hope this helps.
Thank you.