After reading input using std::cin, there will be an extra line left which is read by the getline() everytime.
Try using std::cin.ignore() before reading the string.
It will ignore the extra line.

std::cin>>x;
std::cin.ignore();
std::getline(std::cin,str);
Answer from shubhgkr on Stack Overflow
🌐
HackerRank
hackerrank.com › challenges › 30-data-types › problem
Day 1: Data Types | HackerRank
Day 1: Data Types · Problem · Submissions · Leaderboard · Discussions · Editorial · Tutorial · Objective Today, we're discussing data types. Check out the Tutorial tab for learning materials and an instructional video! Task Complete the code in the editor below.
🌐
HackerRank
hackerrank.com › challenges › 30-data-types › forum
Day 1: Data Types Discussions | Tutorials | HackerRank
var var1 = 0 var var2 = 4.0 var var3 = "" // Read and save an integer, double, and String to your variables. var1 = readLine(); var2 = readLine(); var3 = readLine(); // Print the sum of both integer variables on a new line. console.log(Number(var1) + i) // Print the sum of the double variables on a new line. console.log((Number(var2) + Number(d)).toFixed(1)); // Concatenate and print the String variables on a new line console.log(s + var3) // The 's' variable above should be printed first. ... As someone just now coming in for Java after learning some C# this stuff is wack. Tip: do some looking into how various scanner methods work on value types.
🌐
GitHub
github.com › BiermanM › HackerRank › blob › master › 30 Days of Code › Day 1: Data Types.java
HackerRank/30 Days of Code/Day 1: Data Types.java at master · BiermanM/HackerRank
My solutions to HackerRank problems. Contribute to BiermanM/HackerRank development by creating an account on GitHub.
Author   BiermanM
🌐
GitHub
github.com › LadySith › 30DaysOfCode-Javascript › blob › master › Day 1: Data Types
30DaysOfCode-Javascript/Day 1: Data Types at master · LadySith/30DaysOfCode-Javascript
My javascript solutions to the 30 Days Of Code challenge on HackerRank. - 30DaysOfCode-Javascript/Day 1: Data Types at master · LadySith/30DaysOfCode-Javascript
Author   LadySith
🌐
Tutorials Bookmarks
tutorialsbookmarks.com › home › day 1 data types hackerrank solution in c c++ & java | 30 days of code
Day 1 Data Types Hackerrank Solution In C | 30 Days Of Code
February 18, 2023 - Here in this problem, some data type is already defined they are following, int, double, and string and we have to initialize another data type which is the same int, double, and string for the first data type int we have to perform addition ...
🌐
Blogger
hackerrankcsol.blogspot.com › home › python › day 1: data types - hackerrank solution
Day 1: Data Types - Hackerrank Solution
May 21, 2020 - Complete the code in the editor below. The variables i,d and s are already declared and initialized for you. You must: 1. Declare 3 variables: one of type int, one of type double, and one of type String.
Find elsewhere
🌐
Blogger
codeforalls.blogspot.com › 2017 › 09 › day-1-data-types-hackerrank-solution.html
Day 1: Data Types-hackerrank-solution - Code For Alls..!
September 14, 2017 - The variables , , and are already declared and initialized for you. You must: Declare variables: one of type int, one of type double, and one of type String. Read lines of input from stdin (according to the sequence ...
🌐
Medium
medium.com › @banerjeesaptashwa › 30-days-of-code-in-hackerrank-with-python-day-1-data-types-b17101bfe0e
30 Days of Code in HackerRank With Python (Day 1: Data Types) | by Saptashwa Banerjee | Medium
July 3, 2020 - input() is a syntax used to take input from user and if we add “int” or “float” or “str” in front of them then (it defines what type of data types we want to take input)it take input in the form of integer or float or string. Now we have to just add them in python 3 we can direct add variable in the print operation by simply using the “+”. and this will give the desired output. Well i hope you don’t stuck in any sort of error, Fine! Then just move on to Day 2: Operators.
🌐
CodingBroz
codingbroz.com › home › hackerrank › day 1: data types | 30 days of code | hackerrank solution
Day 1: Data Types | 30 Days Of Code | HackerRank Solution - CodingBroz
June 20, 2021 - Hello coders, today we are going to solve Day 1: Data Type HackerRank Solution in C++, Java and Python which is the part of 30 Days Of Code Series.
🌐
marcuscript
marcuscript.wordpress.com › 2017 › 05 › 11 › 30doc-day-1-data-types
30 Days of Code – Day 1: Data Types - marcuscript
May 16, 2017 - Module Solution Public Shared Sub Main() Dim i As Integer = 4 Dim d As Decimal = 4.0 Dim s As String = "HackerRank " '1: Declarations Dim myi As Integer Dim myd As Double Dim mys As String '2: Integer, double, string saved to variables myi = 12 myd = 4.0 mys = "is the best place to learn and practice coding!"
🌐
CopyAssignment
copyassignment.com › hackerrank-day-1-solution-in-python-data-types
HackerRank Day 1 Solution in Python: Data Types – CopyAssignment
Today we will see the HackerRank Day 1 Solution in Python. The problem is named Data Types which is part of 30 Days of code on HackerRank.
🌐
Blogger
slothcoders.blogspot.com › home › 30 days of code › hackerrank
Day 1: Data Types | 30 Days of Code | Hacker Rank Solution - Sloth Coders
September 12, 2021 - Today we're discussing data types. Complete the code in the editor below. The variables i, d, and s are already declared and initialized for you. You must: 1.
🌐
Medium
wen-mcnair.medium.com › hackerrank-day-1-data-types-d166066a3fb7
(Hackerrank) Day 1: Data Types. Apply your detective skills to this… | by Wendy Raven McNair | Medium
September 23, 2021 - Examples of data types include numbers, strings (think of it as text), and booleans (true or false). Devmountain gives a great introduction to data types in the following YouTube video: ... To ensure the computer can identify and accurately ...
🌐
Medium
medium.com › @AIbatros › day-1-data-types-solution-in-c-python-30-days-of-code-3356ed447ae6
Day 1: Data Types Solution in C# & Python | 30 Days of Code | by Albatros | Medium
October 15, 2024 - Declares a variable s of type string and assigns it the value of the third line of input. Prints the sum of i plus the cast of d to an int on a new line. Prints the concatenation of s with the cast of d to a string on a new line. ... using System; namespace DataTypes { class Program { static void Main(string[] args) { // Read input int i = int.Parse(Console.ReadLine()); double d = double.Parse(Console.ReadLine()); string s =…
🌐
Programming With Basics
programmingwithbasics.com › 2023 › 02 › data-types-hackerrank-solution.html
Day 1 Data Types Hackerrank Solution in C | 30 Days of Code
So here is the logic of the problem Hackerrank Solution For Day 1 Data Types. Here in this problem, some data type is already defined they are following, int, double, and string.
🌐
Hackerrank Solutions
hackerranksolution.com › data-types-hackerrank-solution
Day 1 Data Types Hackerrank Solution | 30 Days of Code
February 26, 2023 - Day 1 Data Types Hackerrank Solution in C. Hackerrank second-day problem we have to find the Day 1 Java Data Types Hackerrank Solution. Declare 3 variables: one of type int, one of type double, and one of type String.
🌐
DEV Community
dev.to › idimaimuna › day-1-data-types-380a
Day 1: Data Types
June 12, 2020 - Python datatypes include: str(string), int(integer), float(float) and bool(boolean). Compared to Java they are few and more manageable (in my opinion) so the challenge was testing accepting input of various types and them printing out the sum ...