Last active
July 5, 2021 13:14
-
-
Save schauhan232/37272c45c8ccde35cca49f153f70b94b to your computer and use it in GitHub Desktop.
HackerRank Day 1 - C# "Data Types"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
class Solution { | |
static void Main(String[] args) { | |
int i = 4; | |
double d = 4.0; | |
string s = "HackerRank "; | |
string prefix = "HackerRank "; | |
// Declare second integer, double, and String variables. | |
int intValue; double doubleValue; string stringValue; | |
// Read and save an integer, double, and String to your variables. | |
intValue = int.Parse(Console.ReadLine()); | |
doubleValue = double.Parse(Console.ReadLine()); | |
stringValue = Console.ReadLine(); | |
// Print the sum of both integer variables on a new line. | |
Console.WriteLine(intValue + i); | |
// Print the sum of the double variables on a new line. | |
Console.WriteLine($"{doubleValue + d:F1}"); | |
// Concatenate and print the String variables on a new line | |
// The 's' variable above should be printed first. | |
Console.WriteLine($"{prefix}{stringValue}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment