Consider an 8 x 8 array for a board game: int board[8][8]; Using two nested loops, initialize the board so that 0s, and 1s alternate as on a checker board.
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
Write a function reverse that takes an array of strings as an argument and reverses it. The function does not return a value. Please do not create a new array. Modify the array parameter.
#include
#include
using namespace std;
void reverse_string(string s[], int size);
void print_array(const string s[], int size);
int main()
{
string words[] = {"Up", "above", "the", "world", "so", "high", "like", "a", "diamond", "in", "the", "sky"};
const int LENGTH = 12;
reverse_string(words, LENGTH);
print_array(words, LENGTH);
return 0;
}
Should print: sky the in diamond a like so world the above Up
Write a C Program that does the following:
1. Declares a C-String called ‘m1’ and initializes it with the text “Programming is great fun!”.
2. Uses C-function puts() to print this string.
3. Asks the user to enter a string named ‘m2’ (Hint: Use gets() function for this.)
4. Concatenates the two strings and stores the result in ‘m3’.
For example, if the user enters m2 as “Not Really!”, m3 should be “Programming is great fun! Not really!”
5. Inserts the user entered array (m2) into m1 after “Programming is ...”
For the above example, the resultant String would become “Programming is Not really! great fun!”
Question Number 4 (CLO 3) (25 marks) Write an object oriented program that will ask the user to enter the specifications of a mobile phone so that the viewers can see them in advertisement form and can compare them for their best choice. Make the program in such a way that user can view the mobiles one by one or all the brands on the same screen. Some Useful Hints Create a class named smart_phone Put the mobile name, price, display size, memory, processor speed, camera and display resolution in private data. A member function will ask the user to enter the data for mobile • Another function will display the data of each object Another function will display the data by combining all the objects (this function will accept 3 objects as argument) and 4th object will be the object on which the function is called. • In main program declare 4 objects • Ask the owner to enter the details for 4 mobiles
Suppose that you are coding a cricket game. For this you need to take care of players, ground, crowd,
equipment (bat, ball, stumps etc) and Umpires. This task is too difficult with structural programming,
that why we need to go for Object Oriented Programming. Use the data modeling technique to find:
• Class(es)
• Object(s) in each class
• Attributes of each object
• Constant Object(s) of each class (if any)
• Method(s) of every class
• Static Data in all classes (if any)