Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Array_reverse.c #36

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions array_reverse.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,32 @@

int main()
{
int arr1[100];
int arr2[100];
int n, i;

printf("Input the size of array : ");
scanf("%d", &n);

int f=n-1;

int arr1[n]; // Declare two arrays according to the size we want
int arr2[n];

printf("Input %d elements in the array :\n", n);
for (i = 0; i < n; i++)

for (i = 0; i < n; i++) //Get values from User
{
printf("Element no %d:", i);
printf("Element no %d:", i+1);
scanf("%d", &arr1[i]);
}
int f=n-1;
for (i=0;i <n ;i++)

for (i=0;i <n ;i++)
{
arr2[i]=arr1[f--];
}
for (i=0;i<n;i++){

printf("\nReverse Order of Array :\n\t");
for (i=0;i<n;i++) //print the reversed elements of array
{
printf("%d ",arr2[i]);
}
}
Expand Down
13 changes: 10 additions & 3 deletions arrays.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
#include <stdio.h>
#include <stdio.h>
int main()
{
int n,i;
int arr[100];

printf("Enter size of the Array : ");
scanf("%d",&n);

int arr[n];

for (i=0;i<n;i++){
printf("Enter value for element %d :",i+1);
scanf("%d",&arr[i]);
}
for (i=0;i<n+1;i++){
printf("\n");
for (i=0;i<n-1;i++){
if (arr[i]>arr[i+1]){
printf("%d\n",arr[i]);
}
}
return 0;
}