Wednesday, July 20, 2011

Program to copy the content of one array into other but in reverse order

/*Serial No.84     [swami58.cpp]*/

#include<stdio.h>
#include<conio.h>
void main()
    {
        int i,j,a[100],b[100];
        printf("How many numbers you want to store:=\n");
        scanf("%d",&j);
        printf("Enter the numbers:=\n");
        for(i=0;i<j;i++)
            {
                scanf("%d",&a[i]);
            }
        for(i=0;i<j;i++)
            {
                b[i]=a[j-i-1];
            }
        printf("Reversed order:=\n");
        for(i=0;i<j;i++)
            {
                printf("%d\n",b[i]);
            }
        getch();
    }

No comments:

Post a Comment

If you have any doubt, feel free to ask...