wap to initialize an array dynamically and print the elements of the array in reverse order. the size of the array and elements of the array are to be taken by the user.




#include<stdio.h>
#include<malloc.h>
void main()
{
int *array,size,i;
printf("enter the size of the array");
scanf("%d",&size);
array=(int*)malloc(size*sizeof(int));
printf("enter the elements");
for(i=0;i<size;i++)
scanf("%d",&array[i]);
for(i=size-1 ;i>=0;i--)
printf("%d",array[i]);
}

NOTE-  i have compiled this program in codeblocks if u do it in turbo c++  use  conio.h  header file in the beginning  and getch()  a the  last

No comments:

Post a Comment

Implemet Stack in python

  class Stack : def __init__ ( self , data ): self . stack = [] if ( data ): self . stack . append ( da...