Commit 0fe10c4a by otsall

lab5

parent ca4233ec
Showing with 28 additions and 0 deletions
#include<stdio.h>
int main(){
int N,
i,
j;
printf("please enter array size\n");
scanf("%d", &N);
int array[N];
for(i = 0; i < N; i++){
printf("what is the array entry at %d?\n", i + 1);
scanf("%d", &array[i]);
}
int swap;
for(i = 0; i < N; i++){
for(j = 0; j < N -1; j++){
if(array[j] < array[j+1]){
swap = array[j];
array[j] = array [j + 1];
array[j + 1] = swap;
}
}
}
printf("printing array starting from the largest value\n");
for(j = 0; j < N; j++){
printf("%d\n", array[j]);
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment