Hello
I have to write a program that, after entering ten elements of an array, will display the array "backwards".
I already have it written, but there is a small problem. In this inverted array, before all these elements, as you can see, I get "0" why?
here is the code:
I corrected the title. - arnoldziq
I have to write a program that, after entering ten elements of an array, will display the array "backwards".
I already have it written, but there is a small problem. In this inverted array, before all these elements, as you can see, I get "0" why?
here is the code:
#include <cstdlib>
#include <stdio.h>
using namespace std;
int main(int argc, char *argv[])
{
int tab[9];
int *wskaznik;
wskaznik=tab;
printf("Wprowadz elementy tablicy 10-cio elementowej: \n\n");
for(int i=0; i<=9; i++)
{
printf("Podaj %d element tablicy: ", i);
scanf("%d", &wskaznik[i]);
}
printf("\nNastepujaca tablica wyswietla elementy wprowadzonej tablicy: \n");
for(int i=0; i<=9; i++,wskaznik++)
{
printf("%d", *wskaznik);
printf("\n");
}
*wskaznik=0;
printf("\nWprowadzone elementy w odwrotnej kolejnosci: \n");
for (int i=10; i>=0; i--)
{
printf("%d", *wskaznik--);
printf("\n");
}
system("PAUSE");
return EXIT_SUCCESS;
}
I corrected the title. - arnoldziq