0
0
C Sharp (C#)programming~10 mins

Variable declaration and initialization in C Sharp (C#) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare an integer variable named age and initialize it with 25.

C Sharp (C#)
int [1] = 25;
Drag options to blanks, or click blank then click option'
Avalue
Bnumber
Cage
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name different from 'age'.
Forgetting to declare the type 'int'.
2fill in blank
medium

Complete the code to declare a string variable named name and initialize it with "Alice".

C Sharp (C#)
string [1] = "Alice";
Drag options to blanks, or click blank then click option'
Atitle
Bname
Clabel
Dtext
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different variable name than 'name'.
Missing the string quotes around "Alice".
3fill in blank
hard

Fix the error in the code by completing the variable declaration for a double named price initialized to 19.99.

C Sharp (C#)
double [1] = 19.99;
Drag options to blanks, or click blank then click option'
Aprice
Bcost
Camount
Dvalue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different variable name than 'price'.
Missing the type declaration 'double'.
4fill in blank
hard

Fill both blanks to declare a boolean variable named isActive and initialize it to true.

C Sharp (C#)
[1] [2] = true;
Drag options to blanks, or click blank then click option'
Abool
Bint
CisActive
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong type like int or string.
Using a variable name other than 'isActive'.
5fill in blank
hard

Fill all three blanks to declare a character variable named grade and initialize it with the letter 'A'.

C Sharp (C#)
[1] [2] = [3];
Drag options to blanks, or click blank then click option'
Achar
Bgrade
C'A'
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using string instead of char.
Using double quotes instead of single quotes for the character.
Using a different variable name than 'grade'.