Fundamentals of Programming Tutorial Sheet
Fundamentals of Programming Tutorial Sheet
TUTORIAL SHEET
1. What is the difference between a runtime error and a logical error? Give one clear
example of each in C++ or Java and explain how to detect and correct them.
2. Define a literal in programming and explain how it differs from a variable. Give examples
of two types of literals used in Java or C++.
3. Write a pseudocode or simple program that uses a do-while loop to keep prompting a
user until they enter a number between 1 and 10.
4. Explain what a data type is and why selecting the right data type matters in
programming. Give examples of two different numeric data types and their common use
cases.
5. Analyze the following code and correct all mistakes. Then explain what the corrected
code does.
#include <iostream>
using namespace std;
int main() {
int data[5];
float result;