1 4 15 7
8 10 2 11
14 3 6 13
12 9 5 ☺

As you can see there is a ☺ at bottom right corner. After implementing the program the above box will display (lines may not be displayed). Allow the user to hit any of the arrow keys (up, down, left, or right).
If user hits say, right arrow key then program should give a message that this movement is not possible.
If user hits left arrow key then 5 should move in place of ☺ and ☺ should move in place of 5, and box will look like:

1 4 15 7
8 10 2 11
14 3 6 13
12 9 ☺ 5

the problem is when i press any arrow key the smiley face does not move please help me.

here is my all code

#include <iostream>
#include<conio.h>
using namespace std;

int main()
{
	int i,j,a,count=0;
	int x[4][4];
	cout<<"\nEnter 15 Integers:\n";
	for(i=0;i<4;i++)

	{
		for(j=0;j<4;j++)
		{
            if (j == 3 && i == 3)
                x[i][j] == '2';
            else
            {
                cin>>x[i][j];
            }

       }
	}

	//output
	for(i=0;i<4;i++)
	{
		for(j=0;j<4;j++)
		{
		   if(j == 3 && i == 3)
		   {
                cout <<"\t"<< '\2'<<"\n\n";
                break;
		   }
           cout <<"\t"<< x[i][j];
           if (j == 3)
			   cout << endl;
       }
	}

	   for( ; ; )
   {
	   a=getch();
	   if((((a==75 && i==0 && j==0) || (a==75 && i==1 && j==0) ||(a==75 && i==2 && j==0) || (a==75 && i==3 && j==0))))
	   	   
			  cout<<"no more possible moves towards left";
			  else
			  if(i==3 && j==3)
			  {
				  x[i][j] == '2';
				  i--;
				  j--;
				  count=count++;
				  cout<<"total moves"<<count;
			  }	   
		   
	   
	   if((((a==77 && i==3 && j==3) || (a==77 && i==2 && j==3) ||(a==77 && i==1 && j==3) || (a==77 && i==0 && j==3))))
	   	   
		      cout<<"no more possible moves towards right";
			  else
			  if(i==3 && j==3)
			  {
				  x[i][j] == '2';
				  i--;
				  j--;
				  count=count++;
				  cout<<"total moves"<<count;
			  }   

	   
	   

	   if((((a==80 && i==3 && j==0) || (a==80 && i==3 && j==1) ||(a==80 && i==3 && j==2) || (a==80 && i==3 && j==3))))
	   
		      cout<<"no more possible moves towards down";
			  else
			  if(i==3 && j==3)
			  {
				  x[i][j] == '2';
				  i--;
				  j--;
				  count=count++;
				  cout<<"total moves"<<count;
			  }

	   
	   

	   if((((a==72 && i==0 && j==0) || (a==72 && i==0 && j==1) ||(a==72 && i==0 && j==2) || (a==72 && i==0 && j==3))))
	   
		      cout<<"no more possible moves towards up";
			  else
			  if(i==3 && j==3)
			  {
				  x[i][j] == '2';
				  i--;
				  j--;
				  count=count++;
				  cout<<"total moves"<<count;
			  } 

			  
	   

	   if(a=='q')
		   break;
   }

	return 0;
}

Yes , If you are using Windows As An OS.

YOU CAN TRY

system(cls);

To Clear the whole thing up and then a printer function added in.

thanks but can you please provide some code as an example

Yes , If you are using Windows As An OS.

YOU CAN TRY

system(cls);

To Clear the whole thing up and then a printer function added in.

I guess you ment

system("cls")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.