Write a piece of code that dynamiccaly creates 1) a 1d char array of size 100 and 2) a 2d array having 4 rows where the first row has only one cell, second row has two cells, third row has three cell, fourth row has four cells. Now write the code to delete the arrays.
What is the difference between a stack and a heap?
What is the size of an int variable and a char variable. What is the size of a variable which points to an int and a variable that points to a char. Now write a piece of code that displays the sizes of the data types mentioned above.
Write the output of the following
int main(){
int array[5]={5,960,87,30,22};
int *aptr = array;
cout << array[0] << *array << *aptr<<endl;
cout << array[4] << *array + 4 << *(array+4) << *(aptr+4);
}
What is the difference between function argument and parameter?
What is the difference between pass by value and pass by reference? Explain using an example.
What are the benefits of using functions?
Write a function which takes as argument two integers and prints all the prime numbers between those two numbers. If the first number is smaller than the second, the prime numbers would be displayed in an increasing order. If the first number is bigger than the second, the prime numbers would be displayed in an decreasing order.
Write a program to play tic tac toe (zero kaataa). (Google tic tac toe if you dont know)
You need to create a 3 by 3 array to represent the game board.
One by one, each player would specify the row and column numbers and that player's symbol would be written to the corresponding array cell. Make sure a player doe not write to an already occupied cell.
At the end of each turn, the table would be drawn on the screen. At the end of each turn, your program should check if any player has won or not.
Game ends when either a player wins or the table is full.
Write a program to play tic tac toe (zero kaataa). (Google tic tac toe if you dont know)
You need to create a 3 by 3 array to represent the game board.
One by one, each player would specify the row and column numbers and that player's symbol would be written to the corresponding array cell. Make sure a player doe not write to an already occupied cell.
At the end of each turn, the table would be drawn on the screen. At the end of each turn, your program should check if any player has won or not.
Game ends when either a player wins or the table is full.