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
|
3978 Discussions
|
Please Login in order to post a comment
c#
Console.Write((i+Convert.ToInt32(Console.ReadLine()))+"\n"+(d+Convert.ToDouble(Console.ReadLine())).ToString("F1")+"\n"+s+Console.ReadLine());
nextLine read leftovers also so after gving input of double we press enter nextLine reads it and returns empty so we need to add 1 more nextLine so that it can read the line we typed after pressing enter ( our input string ).
so we write it like: scan.nextLine(); // to clear buffer String str = scan.nextLine();
//in c++
//in c
include
include
include
include
int main() { int i = 4; double d = 4.0; char s[] = "HackerRank "; int j; double k; char s1[100]; scanf("%d",&j); scanf("%lf",&k); getchar(); fgets(s1,sizeof(s1),stdin); printf("%d\n",i+j); printf("%.1lf\n",k+d); printf("%s%s\n",s,s1);
}