Day 1: Data Types Solution in C# & Python | 30 Days of Code
3 min readDec 23, 2022
Screenshot for those who want to take a look at the question:
Solution in C#
To solve the “Day 1: Data Types” problem on HackerRank using C#, you need to write a program that reads four lines of input from the console and performs the following actions:
- Declares a variable
i
of typeint
and assigns it the value of the first line of input. - Declares a variable
d
of typedouble
and assigns it the value of the second line of input. - Declares a variable
s
of typestring
and assigns it the value of the third line of input. - Prints the sum of
i
plus the cast ofd
to anint
on a new line. - Prints the concatenation of
s
with the cast ofd
to astring
on a new line.
Here is an example solution in C#:
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 =…