Attempt every question

You get marks for every correct bit even if you don't fully understand the question e.g. input data or print.

Read all questions carefully... take your time (unless you're definitely running out!).

The most common reason to lose lots of marks is to slightly misunderstand the question.

Input and Output

print("hello")
Name = input("Please enter your name")

Data Types

  • String - word.
  • Char - one letter.
  • Int - whole number.
  • Double / Float / Real - number with decimal places.
  • Bool - true or false.

If you are asked to choose a data type and give a reason - check the scenario and include the keywords in your answer. For example don't write "it's a whole number" write "words in a book must be a whole number."


Creating variables

int num = 9;
string Surname = "Simpson";
char initial = 'B';
bool hasChildren = false;
double AccountBalanace = 9.99

Sequence

Just means lines of code one after the other e.g.

name = input("What is your name?")
print("hello " + name)

Selection - If and Switch

if (age > 12)
{
    // code here
}

Iteration - means Loops!

If you don't understand what to do with the loop. You'll still get at least one mark for writing out a loop!

Count Controlled - Loops a set number of times

// Loop 10 times - will display the numbers 0 to 9
for (int x = 0; x < 10; x++)
{
    print(x)
}

If you can't remember all parts you can try...

for (x in 1 to 10)
{
    print(x)
}

A kind examiner will probably still give you the marks!


Condition Controlled - Loops while the condition results in true

// will continue to loop until the password entered is "abc"

string password = "";

while (password != "abc")
{
    password = input("please enter password");
}

// will ask first and then check if the password is "abc". If it isn't, it will loop.

string password = "";

do
{
    password = input("please enter password");
} while (password != "abc")

You may also see on questions:

repeat
{
    // code here
} until (/*condition here*/)

Strings

SubString() gets part of the string:

string name = "Bart"
// start at 0 and get 2 letters..
string newStr = name.SubString(0,2)
print(newStr) // will print "Ba"

Upper() converts into upper case (capital letters)

string name = "Bart"
string newStr = name.Upper()
print(newStr)// will print "BART"

Lower() converts into lower case:

string name = "Bart"
string newStr = name.Lower()
print(newStr) // will print "bart"

Functions and Procedures

Functions and Procedures are both sub programs. However, there is a slight difference.. A procedure does something but doesn't return (pass out) any data

public void DoSomething()
{
    // code here
}

A function does something but also returns data. Void is replaced with the data type of the data being returned

public string GreetMe()
{
    return "hello"
}

public int GiveMeANumber()
{
    // generates a random number
    return Random.Next()
}

Calling a function

You must store the data returned in a new variable.

// call the function and store the result in val:
int val = GiveMeANumber();

Functions with Parameters

Parameters pass data in:

// display the number passed in..
public void DisplayNum(int num)
{
    print(num)
}

Multiple Parameters Put commas in between multiple parameters

// display the result of adding the two numbers passed in..
public void AddNums(int FirstNum, int SecondNum)
{
    int result = FirstNum + SecondNum
    print(result)
}

Calling a function with parameters

// call (use) the function by stating its name and passing in the values you want to use..

DisplayNum(99)
AddNums(3, 4)

Hint for Exam Questions on Functions

If the question says use or call: Don't create a function, call the one that already exists (either in the question or if you already made it).

File Handling

Remember Exam File Handling is simpler.

If you are asked to save data:

  1. Open the file.
  2. Save the data.
  3. Close the file.

Sorting

  • Bubble Sort - Bubbles up to the end.
  • Insertion Sort - Inserts to the beginning.
  • Merge Sort - Repeatedly splits array into half until you have one element (item). Then merges back to 2, then to 4, then to 8. Quick but takes lots of space with many arrays.

IDEs

Visual Studio is an IDE! You can

  • breakpoint
  • easily edit your code
  • code is highlighted in different colours e.g. parts of the language are in blue.
  • you can see all your files together

Programming Languages

  • High Level - easier to read but slower to run (like C#).
  • Low Level - harder to read but quicker to run (like assembly).

Testing

Types of Testing:

  • Iterative - as we go along
  • Final

Types of Test Data:

  • Normal
  • Erroneous
  • Boundary

Remember.. you are the elite programmers! Most other programmers nationally won't program like you!