Question

Write a C program using array(s) that inputs 20 re
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the code for you:

#include <stdio.h>
void reverse_array (double data[ ], int n)
{
for(int i = 0; i < n/2; i++)
{
int temp = data[i];
data[i] = data[n-i-1];
data[n-i-1] = temp;
}
}
int main()
{
double Array[20];
int n;
printf("Enter the number of elements: ");
scanf("%i", &n);
printf("Enter %i elements into the array: ", n);
for(int i = 0; i < n; i++)
scanf("%lf", &Array[i]);
printf("Before Reversing: ");
for(int i = 0; i < n; i++)
printf("%.2lf ", Array[i]);
printf("\n");
reverse_array(Array, n);
printf("After Reversing: ");
for(int i = 0; i < n; i++)
printf("%.2lf ", Array[i]);
printf("\n");
}

And the output screenshot is:
Terminal Shell Edit View Window Help 동 -))) 100%圃, Sat 10 Dec 04:20 ANANDA KUMAR THUMMAPUDI a E Currently Open Docum. c array

Add a comment
Know the answer?
Add Answer to:
Write a C program using array(s) that inputs 20 real numbers, then displays it backward on...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT