Coding syntax Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Basic switch statement

A

switch (variable)
{case “condition” or “value “ assigned to variable:
execution eg. Console.write(x);
break;}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Basic for loop

A

For (int i=0 ; i (>=, < , ==) top of range; i++)

{}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Basic If statement

A

If (variable meets condition)
{execution}
else if or else
{execution}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

“Break;” in loop

A

finishes loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

“Continue;” in loop

A

finishes after that iteration of loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Declare a basic subroutine

A

Static void/String name (Int a, Int b)
{ int c= a+b;
Console.Write(c); }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Call basic subroutine

A

name (parameter a, parameter b)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Declare class variable (global variable)

A

static datatype name=x;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Generate a random number between a and b.

A

Random rnd = new Random();
r1=rnd.Next(a,b+1);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Declare a basic array

A

Datatype [] name = new Datatype [i]

where i is no. values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Add the values 7 and 9 to the array Numbers in the 1st and 2nd positions.

A

numbers [0]=7
numbers[1]=9

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Declare a new list

A

Lists <datatype> name;
name = new List <datatype.();</datatype>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Add item to a list

A

name.Add(“x”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Remove value from a list

A

name.Remove(“x”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

No. Items in a list

A

name.Count;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Foreach loop

A

foreach( datatype items in name )
{Console.WriteLine(Items);}