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]
What is a 2D array?
It’s a collection of data elements arranged in a grid-like structure with rows and columns.
// datatype variable[number of rows / arrays] [numbers of columns / values]= {{value, value},{value value}};
What is a structure?
- collection of different data types which the compiler allocates the memory for each member
- size of structure is greater than or equal to the sum of the size of its members
- individual member can be accessed at a time
struct nameOfstruct{
data_type member_name1;
data_type member_name2;
}
What is a union?
- collection of different data types in the same memory location
- the size of union is the same size as the biggest member
- only one member can be accessed
union nameOfunion{
data_type member_name1;
data_type
member_name2;
}
What is a pointer?
It is used to store the memory address of other variables, functions or other pointers.
What are the different file operations?
- fopen() to create a new file / open existing file
- fclose() to close a file
- fscanf() or fgets to read a file
- fprintf() or fputs() to write into a file