What's new

Help C programming reverse

Phantom Rhythm

Honorary Poster
Joined
Sep 10, 2018
Posts
680
Reaction
69
Points
206
Pa help po paano gumawa ng test drive nito, gamit ang odd numbers and even numbers sa element ng array.

#include<stdio.h>

#define SIZE 5

int main(){

int array[SIZE]={1,2,3,4,5},i,j,temp;

for(i=0,j=SIZE-1;i<j;i++,j—){

temp=array;

array=array[j];

array[j]=temp;

}

printf(“Reverse array is:\n”);

for(i=0;i<SIZE;i++){

printf(“%d\n”,array);

}

}
 
Bubble sort po ang gusto mong gawin pero kulang pa po yung code. Pa try po dito You do not have permission to view the full content of this post. Log in or register now. then palitan mo lang yung elements ng array at size.
C:
#include<stdio.h>
int main(){
int size = 5;
int array[]={1,3,2,5,4};
for(int i = 0; i < size ; i++){
    for(int j = 0; j < size - 1; j++){
        if(array[j] > array[j+1]){
            int temp = array[j+1];
            array[j+1] = array[j];
            array[j] = temp;
        }
    }
}
printf("Reverse\n");
for(int l = size - 1; l >= 0; l--)
    printf("%d ", array[l]);
}
 

Similar threads

Back
Top