I'm trying to reverse an array without using any second array. Here's the code I've written, but for some reason it doesn't seems to be working.
#include<stdio.h>
#include<conio.h>
void getarrayvalues();
void main()
{
int k,n;
int i=0;
int a[100];
printf("Enter the value of n");
scanf("%d", &n);
printf("Ener the values of array");
for(i=0;i<n;i++)
{
scanf("%d", &a[i]);
}
k=n;
if(n%2==0)
{
for(i=0;i<n;i++)
{
a[i]=a[k];
k--;
}
}
else
{
for(i=0;i<n;i++)
{
if(k==((n/2)+1))
{
continue;
}
else
{
a[i]=a[k];
k--;
}
}
}
printf("reverse values are");
for(i=0;i<n;i++)
{
printf("%d", a[i]);
}
}
After entering the array values, it returns to the blue code writing screen and doesn't prints the output. Any ideas ?
std::reverse?mainrant:void main()should beint main().