Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Create samiksha_1 #564

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
41 changes: 41 additions & 0 deletions samiksha_1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// C program to copy the contents
// of one array into another
// in the reverse order

#include <stdio.h>

// Function to print the array
void printArray(int arr[], int len)
{
int i;
for (i = 0; i < len; i++) {
printf("%d ", arr[i]);
}
}

// Driver code
int main()
{
int original_arr[] = {1, 2, 3, 4, 5};
int len = sizeof(original_arr)/sizeof(original_arr[0]);

int copied_arr[len], i, j;

// Copy the elements of the array
// in the copied_arr in Reverse Order
for (i = 0; i < len; i++) {
copied_arr[i] = original_arr[len - i - 1];
}

// Print the original_arr
printf("
Original array: ");
printArray(original_arr, len);

// Print the copied array
printf("
Resultant array: ");
printArray(copied_arr, len);

return 0;
}