Programming IL 1
Direction: Describe the following computer programming terms and give example/s.
1). Variable/s
A variable is a piece of data that you can alter that has also been given a name. Many software
applications such as spreadsheets and databases make use of variables. All computer programming
languages can handle variables.
Give (1) example: int age =20;
2). Keywords
In programming, a keyword is a word that is reserved by a program because the word has a special
meaning. Keywords can be commands or parameters. Every programming language has a set of
keywords that cannot be used as variable names. Keywords are sometimes called reserved names .
Give (1) example: auto
3). Basic Operators
In computer programming, an operator is a character that represents an action.
Give (5) types of Operators: Arithmetic Operators
Relational Operators
Logical Operators
Assignment Operators
Bitwise Operators
4). Decision Making
Decision making structures require that the programmer specifies one or more conditions to be
evaluated or tested by the program, along with a statement or statements to be executed if the
condition is determined to be true, and optionally, other statements to be executed if the condition is
determined to be false.
Give (2) examples of decision-making statement:
1.
#include <stdio.h>
int main() {
int x = 2;
switch( x ){
case 1 :
printf( "One\n");
break;
case 2 :
printf( "Two\n");
break;
case 3 :
printf( "Three\n");
break;
case 4 :
printf( "Four\n");
break;
default :
printf( "None of the above...\n");
}
}
2.
#include <stdio.h>
int main() {
int x = 45;
if( x > 95) {
printf( "Student is brilliant\n");
}
else if( x < 30) {
printf( "Student is poor\n");
}
else if( x < 95 && x > 30 ) {
printf( "Student is average\n");
}
}
5). Loops
A loop is a programming structure that repeats a sequence of instructions until a specific condition is
met. Programmers use loops to cycle through values, add sums of numbers, repeat functions, and many
other things.
Give (1) example:
Printing Numbers From 1 to 5
#include <iostream>
using namespace std;
int main() {
for (int i = 1; i <= 5; ++i) {
cout << i << " ";
}
return 0;
}
Output
1 2 3 4 5