write flowchart for the following codes and notice that they are one part of the Q.     *   #include int sortingbook(int array[], int N) {  int count = 0, i , j , k , minimum , index , flag = 0;  for(i=0;ii ; k--)  //shifting one position to the right from index to i    array[k] = array[k-1];    if(array[i]!=minimum)    count++;  //if the value of min chganged from previous assumption    array[i] = minimum;  }  return count; } int main() {  int array[20],i,N,c;  printf("\nEnter number of books(N) : ");  scanf("%d",&N);  //number of books  printf("\nEntercurrent sequence of  %d books :  \n=>   ",N);  for(i=0;i  ");  for(i=0;i #include char box[10]={'0','1','2','3','4','5','6','7','8','9'}; void create_board(); void make_board(int, char); int check_win(); int main() {     int choice,player=1,i;     char mark;     do{         create_board();         player= (player % 2) ? 1: 2;           printf("Player %d, enter a number: ",player);         scanf("%d",&choice);           mark = (player==1) ? 'X' : 'O';         make_board(choice,mark);           i=check_win();         player++;       }while(i == -1);      create_board();       if(i==1)         printf("Player %d  you have won the game",--player);     else         printf("<               Draw             >");         return 0; } void create_board() {     clear_screen;     printf("\n\n\tTic Tac Toe\n\n");     printf("Player 1 (X) -- Player 2 (O)\n\n");     printf("     |     |     \n");     printf(" %c   | %c   | %c   \n",box[1],box[2],box[3]);     printf("__________|________|__\n");     printf("     |     |      \n");     printf(" %c   | %c   | %c   \n",box[4],box[5],box[6]);     printf("__________|__________|__\n");     printf("     |     |      \n");     printf(" %c   | %c   | %c   \n",box[7],box[8],box[9]);     printf("____________|___________|__\n");     printf("     |     |      \n");     } void make_board( int choice, char mark) {     if(choice==1 && box[1]=='1')         box[1]=mark;     else if(choice==2 && box[2]=='2')         box[2]=mark;     else if(choice==3 && box[3]=='3')         box[3]=mark;     else if(choice==4 && box[4]=='4')         box[4]=mark;     else if (choice==5 && box[5]=='5')         box[5]=mark;     else if (choice==6 && box[6]=='6')         box[6]=mark;     else if (choice==7 && box[7]=='7')         box[7]=mark;     else if (choice==8 && box[8]=='8')         box[8]=mark;     else if (choice==9 && box[9]=='9')         box[9]=mark;     else     {         printf("Invalid move");     } }   int check_win() {     if(box[1]==box[2] && box[2]==box[3])         return 1;     else if(box[4]==box[5] && box[5]==box[6])         return 1;                                   // horizontal match     else if (box[7]==box[8] && box[8]==box[9])         return 1;       else if (box[1]==box[4] && box[4]==box[7])         return 1;     else if(box[2]==box[5] && box[5]==box[8])           // vertical match         return 1;     else if(box[3]==box[6] && box[6]==box[9])         return 1;         else if(box[1]==box[5] && box[5]==box[9])         return 1;     else if(box[3]==box[5] && box[5]==box[7])           //diagonal match         return 1;       else if(box[1]!= '1' && box[2]!= '2' && box[3]!= '3' && box[4]!= '4'&& box[5]!= '5' && box[6]!= '6'&& box[7]!= '7' && box[8]!= '8' && box[9]!='9')  //no match         return 0;       else         return -1;     }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

please I need help with this Q , write flowchart for the following codes and notice that they are one part of the Q.

 

 

*

 

#include<stdio.h>
int sortingbook(int array[], int N)
{
 int count = 0, i , j , k , minimum , index , flag = 0;
 for(i=0;i<N;i++)
 {
  minimum = array[i];   //ith element as the minimum
  index = i;          //setting index value as i
  for( j = i; j < N; j++)
  {
   if(array[j] < minimum)
   {
    minimum = array[j];  //calculating minimum
    index = j;     //assigning the minimum position into index
   }
  }
  for(k = index; k>i ; k--)  //shifting one position to the right from index to i
   array[k] = array[k-1]; 
  if(array[i]!=minimum)
   count++;  //if the value of min chganged from previous assumption 
  array[i] = minimum;

 }
 return count;
}
int main()
{
 int array[20],i,N,c;
 printf("\nEnter number of books(N) : ");
 scanf("%d",&N);  //number of books
 printf("\nEntercurrent sequence of  %d books :  \n=>   ",N);
 for(i=0;i<N;i++)
  scanf("%d",&array[i]);  //reading  sqeuence 
 c = sortingbook(array,N);
 printf("\nSorted sequence is :\n=>  ");
 for(i=0;i<N;i++)  //printing final sequence
  printf("%4d",array[i]);
 printf("\nThe minimum number of moves required for sorting : %d\n",c);
 return 0;
}

 

*

 

#include <stdio.h>

#include <term.h>

char box[10]={'0','1','2','3','4','5','6','7','8','9'};

void create_board();

void make_board(int, char);

int check_win();

int main()

{

    int choice,player=1,i;

    char mark;

    do{

        create_board();

        player= (player % 2) ? 1: 2;

 

        printf("Player %d, enter a number: ",player);

        scanf("%d",&choice);

 

        mark = (player==1) ? 'X' : 'O';

        make_board(choice,mark);

 

        i=check_win();

        player++;

 

    }while(i == -1);

 

   create_board();

 

    if(i==1)

        printf("Player %d  you have won the game",--player);

    else

        printf("<               Draw             >");

 

 

    return 0;

}

void create_board()

{

    clear_screen;

    printf("\n\n\tTic Tac Toe\n\n");

    printf("Player 1 (X) -- Player 2 (O)\n\n");

    printf("     |     |     \n");

    printf(" %c   | %c   | %c   \n",box[1],box[2],box[3]);

    printf("__________|________|__\n");

    printf("     |     |      \n");

    printf(" %c   | %c   | %c   \n",box[4],box[5],box[6]);

    printf("__________|__________|__\n");

    printf("     |     |      \n");

    printf(" %c   | %c   | %c   \n",box[7],box[8],box[9]);

    printf("____________|___________|__\n");

    printf("     |     |      \n");

 

 

}

void make_board( int choice, char mark)

{

    if(choice==1 && box[1]=='1')

        box[1]=mark;

    else if(choice==2 && box[2]=='2')

        box[2]=mark;

    else if(choice==3 && box[3]=='3')

        box[3]=mark;

    else if(choice==4 && box[4]=='4')

        box[4]=mark;

    else if (choice==5 && box[5]=='5')

        box[5]=mark;

    else if (choice==6 && box[6]=='6')

        box[6]=mark;

    else if (choice==7 && box[7]=='7')

        box[7]=mark;

    else if (choice==8 && box[8]=='8')

        box[8]=mark;

    else if (choice==9 && box[9]=='9')

        box[9]=mark;

    else

    {

        printf("Invalid move");

    }

}

 

int check_win()

{

    if(box[1]==box[2] && box[2]==box[3])

        return 1;

    else if(box[4]==box[5] && box[5]==box[6])

        return 1;                                   // horizontal match

    else if (box[7]==box[8] && box[8]==box[9])

        return 1;

 

    else if (box[1]==box[4] && box[4]==box[7])

        return 1;

    else if(box[2]==box[5] && box[5]==box[8])           // vertical match

        return 1;

    else if(box[3]==box[6] && box[6]==box[9])

        return 1;

 

 

    else if(box[1]==box[5] && box[5]==box[9])

        return 1;

    else if(box[3]==box[5] && box[5]==box[7])           //diagonal match

        return 1;

 

    else if(box[1]!= '1' && box[2]!= '2' && box[3]!= '3' && box[4]!= '4'&& box[5]!= '5' && box[6]!= '6'&& box[7]!= '7' && box[8]!= '8' && box[9]!='9')  //no match

        return 0;

 

    else

        return -1;

 

 

}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY