Practice
Resources
Contests
Online IDE
New
Free Mock
Scaler
Practice
Improve your coding skills with our resources
Contests
Compete in popular contests with top coders
Scaler
Explore Offerings by SCALER

Begin your success journey!

Sign Up using
Full name *
Email *
Password *

By creating an account, I acknowledge that I have read and agree to InterviewBit’s Terms and Privacy Policy .

Welcome back!

Log In using
Email *
Password *

Variables and Types in C#

 

C# provides a rich set of built-in as well as user defined data types. Most of the built-in data types are described as follows:

  • int : 32 Bit integer , Range (-2,147,483,648 to 2,147,483,647), Default Value is 0.
  • long : 64 bit integer , Range (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807), Default Value is 0L.
  • char : 16-bit Unicode character, Range(U +0000 to U +ffff), Default value is '\0'.
  • bool : Boolean value, Range (either true or false), Default value is false.
  • float : 32-bit single-precision floating point type, Range(-3.4 x 1038 to + 3.4 x 1038), Default Value is 0.0F.
  • double : 64-bit double-precision floating point type, Range((+/-)5.0 x 10-324 to (+/-)1.7 x 10308), Default Value is 0.0D.

To learn more types of built-in data types please refer here.

 

 

User Defined data types are structures (struct) and classes (class). This will be covered later in the course.

Variables

In programming, a variable is a container (storage area) to hold data.

To indicate the storage area, each variable should be given a unique name (identifier). For example,

int val = 10;
// Here, val is a variable of the int data type, and we have assigned an integer value 10 to it.
// Also, we can change the value of the variable
val = 15;

Try the following example in the editor below.

You have to input 5 lines containing values: int, long, char, float and double respectively and print them in the same order in new line.

Example Input:

5 
1234567891231
z
24.23
1214523.028352

Example Output:

5
1234567891231
z
24.23
1214523.028352

Start solving Variables and Types in C# on Interview Code Editor
Hints
  • Complete Solution

Discussion


Loading...
Click here to start solving coding interview questions
Free Mock Assessment
Fill up the details for personalised experience.
All fields are mandatory
Current Employer *
Enter company name *
Graduation Year *
Select an option *
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
Phone Number *
OTP will be sent to this number for verification
+1 *
+1
Change Number
Graduation Year *
Graduation Year *
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
*Enter the expected year of graduation if you're student
Current Employer *
Company Name *
Please verify your phone number
Edit
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.
Already have an account? Log in
Free Mock Assessment
Instructions from Interviewbit
Start Test