Question

In C, while loop cannot be used to manipulate one-dimensional arrays. True or False

In C, while loop cannot be used to manipulate one-dimensional arrays. True or False

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The above statement is False. Means we can manipulate the one-dimensional arrays using while loop. With the help of the loop we can check the condition and then we can manipulate the array.

For example:

code:

#include <stdio.h>
int main()
{
int a[10];//intializing array
int i=0, n, sum = 0, avg;
printf("Enter length of array: ");
scanf("%d", &n);
//checking the length of the array
while(i<n)
{
printf("Enter number %d: ",i+1);
scanf("%d", &a[i]);
sum += a[i];
i++;
}
avg = sum/n;
//printing the Average
printf("Average = %d", avg);

return 0;
}

Here the above example is used to find the average of the numbers in array . with the help of the while loop we just added the numbers to array and then increments the array length.

Add a comment
Know the answer?
Add Answer to:
In C, while loop cannot be used to manipulate one-dimensional arrays. True or False
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
ADVERTISEMENT