reverse array using array and pointers

20 views
Skip to first unread message

praveen narayanan CSE

unread,
Oct 15, 2020, 4:32:52 AM10/15/20
to Discussion forum for Introduction to Programming in C
#include<stdio.h>
void rev_array(int* a,int n){

int* b = a+n-1;
while(b>a){
swap(a,b);
a=a+1;
b=b-1;
}
printf("%d",a);
}

void swao(int* ptra,int* ptrb)
{

int t=*ptra;
*ptra=*ptrb;

*ptrb=t;
}

int main(){

int c[]={1,2,3,4};
int n=4;
rev_array(c,n);

}
sir I write this code for reverse array but this code  showing error please correct my code
please.
Reply all
Reply to author
Forward
0 new messages