Write a program to accept 10 numbers and print it in reverse order.(Do not use array)‌

int main()
{
static int n=10;
if(n--==0)
return 0;
else
{
int x;
scanf("%d",&x);
main();
printf("%d\n",x);
}
return 0;
}



*****************************  Or   *****************************


// Using Pointer pointer


#include<stdio.h>
 

void main()
{
 

int *ptrint;
int ptr;
int i;

clrscr();

ptrint = &ptr;

printf("\nEnter 10 numbers :\n");

for(i=0;i<10;i++)
{
scanf("%d",ptrint);
ptrint++;

}
ptrint--;
printf("\n10 Numbers in reverse order.\n");
for(i=0;i<10;i++)
{
printf("%d\n",(int)*ptrint);
ptrint--;
}
getch();

}

0 comments:

Post a Comment