We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 1: Data Types
Day 1: Data Types
Sort by
recency
|
3935 Discussions
|
Please Login in order to post a comment
int a; double b; char str[100],res[100]; scanf("%d",&a); scanf("%lf",&b); getchar(); //it is used to cosume previous newline from scanf fgets(str,sizeof(str),stdin); printf("%d\n",(a+i)); printf("%.1f\n",(b+d)); strcpy(res,s); strcat(res,str); printf("%s",res);
The hardest part about this question in C++ was that the input variables are not clear.
Based on the instructions, I interpreted it as: - outputRequest1: input int + input double; - outputRequest2: input double + input double; - outputRequest3: "HackerRank " + getline(input string); But you acutally need to manually add numbers + the inputs and eat whitespace for the string.
i need help with the c++ my float will not work and my string only returns one word. i even tried using getline(cin ,str) but it just failed entirely i have done this in c++14 and c++20 someone please
JAVA Solution.
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
python3 code
Read input valuse
int_input = int(input().strip()) double_input = float(input().strip()) string_input = input().strip()
Perfom the required operations
int_sum = i + int_input** double_sum = d + double_input concatenated_string = s + string_input
print the results print(int_sum) print(f"{double_sum:.1f}") print(concatenated_string)