Question

In: Computer Science

Backtracking Write a program in c++ that moves an asterisk ‘*’ in a grid of 10x10...

Backtracking

Write a program in c++ that moves an asterisk ‘*’ in a grid of 10x10 cells. Your program should start with * on position (2,3) i.e. 3rd column of 2nd row. After printing the grid and ‘*’, your program will ask user if he wants to move the ‘*’ Up, Down, Left or Right. If user presses ‘U’, ‘D’, ‘L’ or ‘R’, your program will move the ‘*’ one position accordingly. If user presses ‘Q’, your program should terminate.

2- There should not be any Memory Leakage in your code.

3- Your code should be readable and properly commented and interface of your program should be user friendly.

Solutions

Expert Solution

// File Name: StackStar.h
#ifndef _STACKSTAR
#define _STACKSTAR

#include <iostream>
#include <string>
#define MAX 100
using namespace std;

// Defines a template type class Stack
class StackStar
{
private:
// To store data
char *backtrack;
// To point to top
int top;
// Function to return top value
int getCurrentTop()
{
return top;
}
// Function to change top value
void setCurrentTop(int s)
{
top = s;
}
public:
// Prototype of member functions
StackStar();
bool isEmpty();
bool push(char);
bool pop();
char peek();
void clean();
bool display();
};// End of class


// Default constructor to set stack top to -1
StackStar::StackStar()
{
backtrack = new char[MAX];
setCurrentTop(-1);
}// End of constructor

// Function to return true if stack is empty otherwise returns false
bool StackStar::isEmpty()
{
// Checks if top value is -1 then returns true otherwise returns false
return(top == -1);
}// End of function

// Function to push an item at the top of the stack
bool StackStar::push(char opt)
{
// Checks if stack top value is equals to 99, then return false (stack is full)
if (top == 99)
{
cout << "stack is full\n";
return false;
}// End of if condition

// Otherwise stack is not full
else
{
// Assigns parameter value to stack top position
// increase the stack top by one
backtrack[++top] = opt;

// returns true for successfully pushed data
return true;
}// End of else
}// End of function

// Function to pop an item from the top of the stack
bool StackStar::pop()
{
// Calls the function to check stack is empty then return false
if (isEmpty())
{
cout << "pop failed, stack is empty\n";
return false;
}// End of if condition

// Otherwise stack is not empty
else
{
// Decrease the top index value by one
top--;
// returns true for successfully popped item
return true;
}// End of else
}// End of function

// Function to return the stack top element
char StackStar::peek()
{
// Calls the function to check stack is empty then return false
if (isEmpty())
{
cout << "stack is empty program aborted \n";
exit(0);
}// End of if condition

// Otherwise stack is not empty
else
{
// Returns the stack top index position element
return backtrack[top];
}// End of else
}// End of function

// Function to delete all the element from the stack
void StackStar::clean()
{
// Calls the function to set stack top position to -1
setCurrentTop(-1);
}// End of function
#endif
---------------------------------------------------------------------------------------------------------------

// File Name: MoveStar.cpp
#include <iostream>
#include <cstdlib>
#include "StackStar.h"
#define MAXR 10 // Maximum number of rows for board
#define MAXC 10 // Maximum number of columns for board
using namespace std;

/**
* Function to move the star to one position up in the board
* Parameters:
* ss - Stack object to store the movement. Returns by reference
* board - Character type matrix to represent board data
* r - Current row index position
* c - Current column index position
* Return:
* Returns the updated row using pass by reference
*/
void moveUp(StackStar &ss, char board[][MAXC], int &r, int c)
{
// Checks if after subtracting one from the row it is equals to -1
// then display error message
if(r - 1 == -1)
cout<<"\n Cannot move up. At first row."<<endl;

// Otherwise valid position
else
{
// Assigns space to current row and column position of the matrix board
// to remove the '*'
board[r][c] = ' ';
// Decrease the row index by one and assigns '*'
board[--r][c] = '*';
// Pushes the operation to stack
ss.push('U');
}// End of else
}// End of function

/**
* Function to move the star to one position down in the board
* Parameters:
* ss - Stack object to store the movement. Returns by reference
* board - Character type matrix to represent board data
* r - Current row index position
* c - Current column index position
* Return:
* Returns the updated row using pass by reference
*/
void moveDown(StackStar &ss, char board[][MAXC], int &r, int c)
{
// Checks if after adding one to the row it is equals to maximum row
// then display error message
if(r + 1 == MAXR)
cout<<"\n Cannot move down. At last row."<<endl;

// Otherwise valid position
else
{
// Assigns space to current row and column position of the matrix board
// to remove the '*'
board[r][c] = ' ';
// Increase the row index by one and assigns '*'
board[++r][c] = '*';
// Pushes the operation to stack
ss.push('D');
}// End of else
}// End of function

/**
* Function to move the star to one position left in the board
* Parameters:
* ss - Stack object to store the movement. Returns by reference
* board - Character type matrix to represent board data
* r - Current row index position
* c - Current column index position
* Return:
* Returns the updated column using pass by reference
*/
void moveLeft(StackStar &ss, char board[][MAXC], int r, int &c)
{
// Checks if after subtracting one from the column it is equals to -1
// then display error message
if(c - 1 == -1)
cout<<"\n Cannot move left. At first column."<<endl;

// Otherwise valid position
else
{
// Assigns space to current row and column position of the matrix board
// to remove the '*'
board[r][c] = ' ';
// Decrease the column index by one and assigns '*'
board[r][--c] = '*';
// Pushes the operation to stack
ss.push('L');
}// End of else
}// End of function

/**
* Function to move the star to one position right in the board
* Parameters:
* ss - Stack object to store the movement. Returns by reference
* board - Character type matrix to represent board data
* r - Current row index position
* c - Current column index position
* Return:
* Returns the updated column using pass by reference
*/
void moveRight(StackStar &ss, char board[][MAXC], int &r, int &c)
{
// Checks if after adding one to the column it is equals to maximum column
// then display error message
if(c + 1 == MAXC)
cout<<"\n Cannot move right. At last column."<<endl;

// Otherwise valid position
else
{
// Assigns space to current row and column position of the matrix board
// to remove the '*'
board[r][c] = ' ';
// Increase the column index by one and assigns '*'
board[r][++c] = '*';
// Pushes the operation to stack
ss.push('R');
}// End of else
}// End of function

/**
* Function to undo move the star to one position up in the board
* Parameters:
* ss - Stack object to store the movement. Returns by reference
* board - Character type matrix to represent board data
* r - Current row index position
* c - Current column index position
* Return:
* Returns the updated row using pass by reference
*/
void undoMoveUp(char board[][MAXC], int &r, int c)
{
// Assigns space to current row and column position of the matrix board
// to remove the '*'
board[r][c] = ' ';
// Decrease the row index by one and assigns '*'
board[++r][c] = '*';
}// End of function

/**
* Function to undo move the star to one position down in the board
* Parameters:
* ss - Stack object to store the movement. Returns by reference
* board - Character type matrix to represent board data
* r - Current row index position
* c - Current column index position
* Return:
* Returns the updated row using pass by reference
*/
void undoMoveDown(char board[][MAXC], int &r, int c)
{
// Assigns space to current row and column position of the matrix board
// to remove the '*'
board[r][c] = ' ';
// Decrease the row index by one and assigns '*'
board[--r][c] = '*';
}// End of function

/**
* Function to undo move the star to one position left in the board
* Parameters:
* ss - Stack object to store the movement. Returns by reference
* board - Character type matrix to represent board data
* r - Current row index position
* c - Current column index position
* Return:
* Returns the updated column using pass by reference
*/
void undoMoveLeft(char board[][MAXC], int r, int &c)
{
// Assigns space to current row and column position of the matrix board
// to remove the '*'
board[r][c] = ' ';
// Increase the column index by one and assigns '*'
board[r][++c] = '*';
}// End of function

/**
* Function to undo move the star to one position right in the board
* Parameters:
* ss - Stack object to store the movement. Returns by reference
* board - Character type matrix to represent board data
* r - Current row index position
* c - Current column index position
* Return:
* Returns the updated column using pass by reference
*/
void undoMoveRight(char board[][MAXC], int &r, int &c)
{
// Assigns space to current row and column position of the matrix board
// to remove the '*'
board[r][c] = ' ';
// Decrease the column index by one and assigns '*'
board[r][--c] = '*';
}// End of function

// Function to display menu, accept user choice and returns user choice
char menu()
{
char choice;
cout<<"\n\n **************** Move Menu **************** ";
cout<<"\n U - UP \n D - Down \n L - Left \n R - Right \n Z - Undo \n Q - Quit \n\t What is your choice? ";
cin>>choice;
return choice;
}// End of function

// Function to assign space character to each cell of the board
void initBoard(char board[][MAXC])
{
// Loops till number of rows
for(int r = 0; r < MAXR; r++)
// Loops till number of columns
for(int c = 0; c < MAXC; c++)
// Assigns space character to current cell
board[r][c] = ' ';
}// End of function

// Function to display the board
void showBoard(char board[][MAXC])
{
// Loops till number of rows
for(int r = 0; r < MAXR; r++)
{
// Loops till number of twice the size of number of rows add 1
// to display row line
for(int l = 0; l < (MAXR * 2) + 1; l++)
cout<<"-";
cout<<endl;

// Loops till number of rows
for(int c = 0; c < MAXC; c++)
// Displays the current cell value
cout<<"|"<<board[r][c];
cout<<"|"<<endl;
}// End of for loop

// Loops till number of twice the size of number of rows add 1
// to display row line
for(int l = 0; l < (MAXR * 2) + 1; l++)
cout<<"-";
}// End of function

// main function definition
int main()
{
StackStar ss;
char undoOpt;
// Character array to represent board
char board[MAXR][MAXC];
// Initial row position
int r = 2;
// Initial column position
int c = 3;
// Calls the function to create the board
initBoard(board);

// Assigns '*' to current row and column index
board[r][c] = '*';

// Loops till user choice is not 'Q' or 'q'
do
{
// Call the function to display the board
showBoard(board);

// Calls the function to accept user choice
// Calls respective function based on returned user choice
switch(menu())
{
case 'U':
case 'u':
moveUp(ss, board, r, c);
break;
case 'D':
case 'd':
moveDown(ss, board, r, c);
break;
case 'L':
case 'l':
moveLeft(ss, board, r, c);
break;
case 'R':
case 'r':
moveRight(ss, board, r, c);
break;
case 'Z':
case 'z':
// Checks if stack is empty then display error message
if(ss.isEmpty())
cout<<"\n Nothing to undo.\n";

// Otherwise stack is not empty
else
{
// Extracts the stack top position operation
undoOpt = ss.peek();
// Removes the stack top position operation
ss.pop();

// Checks the operation and calls appropriate function
switch(undoOpt)
{
case 'U':
undoMoveUp(board, r, c);
break;
case 'D':
undoMoveDown(board, r, c);
break;
case 'L':
undoMoveLeft(board, r, c);
break;
case 'R':
undoMoveRight(board, r, c);
break;
}// End of inner switch - case
}// End of else
break;
case 'Q':
case 'q':
cout<<"\n\t Thanks.";
exit(0);
default:
cout<<"\n Invalid choice!!"<<endl;
}// End of switch - case
}while(1);// End of do - while loop
return 0;
}// End of main function

Sample Output:

---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | |*| | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? u
---------------------
| | | | | | | | | | |
---------------------
| | | |*| | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? u
---------------------
| | | |*| | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? u

Cannot move up. At first row.
---------------------
| | | |*| | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? z
---------------------
| | | | | | | | | | |
---------------------
| | | |*| | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? z
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | |*| | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? z

Nothing to undo.
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | |*| | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? r
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | |*| | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? r
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | |*| | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? r
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | |*| | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? d
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | |*| | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? d
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | |*| | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? z
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | |*| | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? z
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | |*| | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? z
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | |*| | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? z
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | |*| | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? z
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | |*| | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? z

Nothing to undo.
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | |*| | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------
| | | | | | | | | | |
---------------------

**************** Move Menu ****************
U - UP
D - Down
L - Left
R - Right
Z - Undo
Q - Quit
What is your choice? q

Thanks.


Related Solutions

There lays a 10x10 square grid in front of Claire and she is instructed to stand...
There lays a 10x10 square grid in front of Claire and she is instructed to stand in the lower left square of the grid. She is asked to make her way to the top right square of the grid but she can only move 1 square up or 1 square to the right at a time. 1. In how many ways could she make a path to the top right corner? 2. In how many ways could she make a...
Write a rudimentary spreadsheet program using C++. Display a grid of cells with columns A through...
Write a rudimentary spreadsheet program using C++. Display a grid of cells with columns A through H and rows 1 through 20. Accept input in the first row of the screen. The commands are of the form column row entry, where entry is a number, a cell address preceded by a plus (e.g., +A5), a string, or a function preceded by an at sign, @. The functions are: max, min, avg, and sum. During execution of your program, build and...
Complete the 8 queens 1 dimensional array program with backtracking in c+++. (don't use go to...
Complete the 8 queens 1 dimensional array program with backtracking in c+++. (don't use go to statement ) and please describe all the code statement and show the code in complier and also which can be copied. thank you very much
Write pseudocode (C++) that will create a 50 x 50 grid of nodes and an output...
Write pseudocode (C++) that will create a 50 x 50 grid of nodes and an output function that displays the row and column of each node in the grid after it is created. -Creating the grid -Printing the grid -Deleting the grid • For each function o Determine the parameters and return type o Detail the step-by-step logic that the function will perform
Develop a python program to - Create a 2D 10x10 numpy array and fill it with...
Develop a python program to - Create a 2D 10x10 numpy array and fill it with the random numbers between 1 and 9 (including 0 and 9). - Assume that you are located at (0,0) (upper-left corner) and want to move to (9,9) (lower-right corner) step by step. In each step, you can only move right or down in the array. - Develop a function to simulate random movement from (0,0) to (9,9) and return sum of all cell values...
Program in C: Write a program in C that reorders the elements in an array in...
Program in C: Write a program in C that reorders the elements in an array in ascending order from least to greatest. The array is {1,4,3,2,6,5,9,8,7,10}. You must use a swap function and a main function in the code. (Hint: Use void swap and swap)
Write a program in C (NOT C++ or C#) The program inputs 5 elements into each...
Write a program in C (NOT C++ or C#) The program inputs 5 elements into each of 2 integer arrays. Multiply corresponding array elements, that is, arrayOne[0] * arrayTwo[0], etc. Save the product into a third array called prodArray[ ]. Display the product array.
CS 400 Assignment 5 Recursive/Backtracking: Generating Permutations WRITE CODE IN C++ PROGRAMMING LANGUAGE WITH COMMENTS INCLUDED...
CS 400 Assignment 5 Recursive/Backtracking: Generating Permutations WRITE CODE IN C++ PROGRAMMING LANGUAGE WITH COMMENTS INCLUDED Description: Mimic the code for N-queen problem (https://introcs.cs.princeton.edu/java/23recursion/Queens.java.html), develop a program that generates all permutations for the set {1, 2, 3, 4, 5}. The output should contain all 5! = 120 permutations. Output Sample: P#1: 1 2 3 4 5 P#2: 1 2 3 5 4 P#3: 1 2 4 3 5 ... P#120: 5 4 3 2 1 Hint: - Thoroughly study the...
Write down the C++ Program
 Write a function, which accept three integer values as arguments find the largest of three and then return the largest value to main program. Write a main program which will call the function by passing three integer values and print the value returned by the function.?
write pseudocode not c program If- else programming exercises 1.    Write a C program to find...
write pseudocode not c program If- else programming exercises 1.    Write a C program to find maximum between two numbers. 2.    Write a C program to find maximum between three numbers. 3.    Write a C program to check whether a number is negative, positive or zero. 4.    Write a C program to check whether a number is divisible by 5 and 11 or not. 5.    Write a C program to check whether a number is even or odd. 6.    Write...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT