Question: C programming Go through this program. Trace the code for at least 5 iteration and give your comment on what this is doing ? #include

C programming

Go through this program. Trace the code for at least 5 iteration and give your comment on what this is doing ?

#include #include #include

int main ( ) {

// card is an array with 24 cells, each cell is of type char pointer // The strings are constant, the address of the first character // is constant and can't be changed.

// we assign that address to the cells in the array // This is similar to char *p = "Sample String" ;

char *card[24] = { "spade-one", "spade-two", "spade-three", "spade-four", "spade-five", "spade-six", "heart-one", "heart-two", "heart-three", "heart-four", "heart-five", "heart-six", "diamond-one", "diamond-second", "diamond-three", "diamond-four", "diamond-five", "diamond-six", "club-one", "club-two", "club-three", "club-four", "club-five", "club-six" } ;

char *player1[6], *player2[6], *player3[6], *player4[6];

int i ;

// Question1: TRACE THIS CODE FOR AT LEAST FIVE ITERATIONS // WHAT AM I DOING ? // WHAT AM I SWAPPING , VALUES, ADDRESSES? // GIVE AS MUCH AS DETAILS AS POSSIBLE srand( time ( NULL ) ); for ( i = 0 ; i < 24 ; i++ ) { char *temp ; int cardNo = rand( ) % ( 24 - i ) ; temp = card [ cardNo ] ; card [ cardNo ] = card [ 24 - i - 1 ] ; card [ 24 - i - 1 ] = temp ; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!