Monday 5 October 2015

Write a program to read array of integers and print it in reverse order

  
   
#include<stdio.h>
//#include<conio.h>
void main() {
    int i, j = 0, a[10], b[10];
    //clrscr();
    for (i = 0; i < 10; i++) {
        printf("enter value of a[%d]= ", i);
        scanf("%d", &a[i]);
    }
    for (i = 9; i >= 0; i--) {
        b[j] = a[i];
        j++;
    }
    printf("reverse of array is= \n");
    for (j = 0; j < 10; j++) {
        printf("b[%d]=%d", j, b[j]);
        printf("\n");
    }
    //getch();
}
Note: Remove the comment line when you are use Turbo C IDE for run your program.

No comments:

Post a Comment