img
Question:
Published on: 22 December, 2024

Describe a string reversal algorithm. Write the difference between a [ ] [ ] and  **a.

Answer:

String Reversal Algorithm:

strrevers()
{
    char str[50];
    char rev[50];
    int i=-1,j=0;

    printf("Enter any string : ");
    gets(str);
    while(str[++i]!='\0')
        while(i>=0)
             rev[j++] = str[--i];

    rev[j]='\0';
  
    printf("Reverse of string is : %s",rev);
}

Difference between a [ ] [ ] and **a:

a[ ][ ] is represent two dimensional array.

**a represent pointer to pointer.

 
Random questions