Basic Definitions Flashcards
What are variables?
Variables are the user defined names given to a memory location which is used for storing data.
What are datatypes?
Datatypes specify the type of data a variable can store.
What are format specifiers?
Format specifiers are used to define the type of data to be displayed.
What are constants?
Constants are names given to variables whose value can’t be changed.
What are operators?
Operators are symbols used to perform specific operations on operands.
Name the arithmetic operators.
+plus
-minus
*multiply
/divide
&modulus
++increment
–decrement
Name the relational operators.
< less than
> greater than
<= less than or equal to
>= greater than or equal to
== equal to
!= not equal to
What are loops? Name the different types of loops.
Loops are used to repeat a block of code until the specified condition is met.
- for loops
for(initialization; condition; updation){
// code to be executed;
} - do-while loops
do{
// code to be executed
} while (condition); - while loops
while(condition){
// code to be executed;
updation;
} - nested loops
What are if statements?
If statements are decision-making statements that executes a block of code if the condition is met.
if(// condition){
// code to be executed
}
What are switch statements?
A more efficient way to using many else if statements.
switch(// name of variable){
case 1;
// code to be executed
break;
case 2;
// code to be executed
break;
default: // on the last case
}
What is a function?
A block of code which only runs when it is called.
void functionName(){
// code to be executed
}
functionName() // to call the function
What is the difference between arguments and parameters?
Arguments
- the values sent to the function
- written at the bottom ()
functionName(// variable)
Parameters
- the values received by the function when its called
- written at the top (in the function)
void functionName(// datatype variable)
What is the difference continue and break?
- Continue skips the rest of the code & forces the next iteration of the loop
- Break exits out of a loop or a switch completely once the condition is met
Name the logical operators and explain them.
&&Logical AND (returns true only if all the conditions are true)
||Logical OR (returns false only if all the conditions are false)
!Logical NOT (returns TRUE when condition
is FALSE, returns FALSE when condition is TRUE)
What is an array?
It is a data structure that can store many values of the same data type.
// datatype variable[size] = {value, value};
// to access
// name of variable [index number]