Q:

how to take entire line as input to a string variable after taking a double as input?

aim: write a program in c++
1.Declare  variables: one of type double, and one of type String.
2.Print the sum of  your double variable to a scale of one decimal place on a new line.
3.Concatenate  with the string you read as input and print the result on a new line.
 (complete this program )
 int main()
 {

double d = 4.0;
string s = "hello and welcome ";

//write ur code here
//  double variable
//string variable
//i/p double from user
// i/p string from user
// print sum of double
// print concatenated string 

}
sample i/p=---
 4.0
umang mahant!
sample o/p----
8.0
hello and welcome umang mahant!
 //this is my code but it isnt taking the line as input i really dont know why?
   #include <iostream>
   #include <iomanip>
   #include <limits>

   using namespace std;

   int main() {
   double d = 4.0;
   string s = "hello and welcome ";
   double b;
   string s2;
   cin>>b;
   getline(cin, s2, '\n');
   cout<<d+b<<"\n";
   cout<<s<<s2<<"\n";
   }

A:

First change s to 
s = "hello and welcome"

Then have a look at following code
#include <strtk.hpp>

double sum = d + b ; // adding doubles 

std::string sum_as_string = strtk::type_to_string<double>(sum); //converted sum to string

std::string final_string = sum_as_string + s2 + s;//concatenate your input string to sum string  and s string

Now print the final_string.
(You were not concatenating strings in real , printing them together is not a solution ! )
After getline(cin, s2) insert this code and delete two cout statements then at last write
 cout<<final_string<<"\n";

If you dont want to concatenate strings in real then you can just correct input function getline.
Answer to your hackerrank challenge
int p;
double q;
string s2,result;

// Declare second integer, double, and String variables.

// Read and save an integer, double, and String to your variables.
cin>>p;
cin>>q;
getline(cin >> ws ,s2);

// Note: If you have trouble reading the entire string, please go back and review the Tutorial closely.

// Print the sum of both integer variables on a new line.
cout<<p+i<<"\n";

// Print the sum of the double variables on a new line.
std::cout << std::fixed;
std::cout << std::setprecision(1);
cout<<q+d<<"\n";
// Concatenate and print the String variables on a new line
result = s + s2;
cout<<result<<"\n";

