Data Type Solution in C#
This Page Contains the Solution in C# Programming Language for the Day 1 : Data Type, Code Challange of the HackerRank 30 Days of Code.
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 ";
// Declare second integer, double, and String variables.
int j; //Integer
double e; //Double
string NewString; //String
// Read and save an integer, double, and String to your variables.
j = Convert.ToInt32(Console.ReadLine());
e = Convert.ToDouble(Console.ReadLine());
NewString = Console.ReadLine();
// Print the sum of both integer variables on a new line.
Console.WriteLine(j + i);
// Print the sum of the double variables on a new line.
Console.WriteLine("{0:F1}", d + e);
// Concatenate and print the String variables on a new line
// The 's' variable above should be printed first.
Console.WriteLine(s + NewString);
}
}
Last updated
Was this helpful?