Easy Tutorial
❮ C Variable Arguments C Examples Access Array Pointer ❯

C Practice Example 90

C Language Classic 100 Examples

Title: A question from the special promotion to undergraduate program, read the result.

Program Analysis: None.

Program Source Code:

//  Created by www.tutorialpro.org on 15/11/9.
//  Copyright © 2015 tutorialpro.org. All rights reserved.
//

#include<stdio.h>
#include<stdlib.h>

#define M 5
int main()
{
    int a[M]={1,2,3,4,5};
    int i,j,t;
    i=0;j=M-1;
    while(i&lt;j)
    {
        t=*(a+i);
        *(a+i)=*(a+j);
        *(a+j)=t;
        i++;j--;
    }
    for(i=0;i&lt;M;i++) {
        printf("%d\n",*(a+i));
    }

}

The output result of the above example is:

5
4
3
2
1

C Language Classic 100 Examples

❮ C Variable Arguments C Examples Access Array Pointer ❯