Write a C program that: 1. Creates an array of integers of size 5 having the following values? {2,2,5,1,3}?
-
2. Squares each element in the array. (Use the property that the name of the array is a pointer to the first element in the array) 3. Find the product of the elements of the array. (Use the property that the name of the array is a pointer to the first element in the array) i just need part 3 please !=]
-
Answer:
int a[]={2,2,5,1,3}; int product(int []); ... int product(r[]){ int i,pro=1; for(i=0;i<5;i++) pro*=r[i]; return pro; }
Duaa-07 at Yahoo! Answers Visit the source
Other answers
int a[]={2,2,5,1,3},i,prduct=1; for(i=0;i<5;i++) a[i]=a[i]*a[i]; //second step// You can write as *(a+i) *= *(a+i); for(i=0;i<5;i++) product *=a[i]; //try product *= *(a+i); printf("%d\n", product);
James Bond
Related Q & A:
- How to run an executable from within a c program?Best solution by Stack Overflow
- What's the average/normal weight for a 13 year old girl who is 5'1?Best solution by Yahoo! Answers
- How to write a TV program proposal?
- Is there a Jailbreak For Ipod Touch 3g 3.1.3?Best solution by Yahoo! Answers
- Write a balanced net ionic equation for the following reaction?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.