# Using pointer, how i can get the average from 2+4+8+16+...........+2048?

I make a code,,,,,, but may be here some problem.......

# define n_num 11

int main() { int arr[11]; int i, total; total=0; for (i=2; i<2048;) { arr[i]=i*2; total=total+arr[i]; } printf("The average=%f\n", (float)total/n_num); return 0; }

unipro4urs
91

2+4+8+16+...........+2048 এই ভেলু গুল কি আগে থেকেই কোন অ্যারে তে জমা করা আছে ?

(07 Dec '16, 13:27)

 0 আমি ধরে নিলাম 2+4+8+16+...........+2048 এই ভালু গুল int dara[]; নামের অ্যারে তে জমা করা আছে । এখন আপনি যদি পয়েন্টের বাবহার করে এই ডাটা গুলির avg বের করতে চান তবে নিচের মত করে কোড লিখতে পারেন কোড : `````` for(int i = 0; i < size; i++) { total = total + *(data + i); // access the value by *(data + i) and sum it to total } printf("avg: %lf\n", total / size); `````` ধন্যবাদ answered 07 Dec '16, 13:38 menon 4.7k●3●35 You comment in answer section. Please comment in comment section and if you got your answer than AC it :) @unipro4urs (11 Dec '16, 16:01) menon
 0 Thank you very much answered 11 Dec '16, 15:40 unipro4urs 9●1
 0 can anyone write the whole program.............? answered 20 Dec '16, 01:11 unipro4urs 9●1

# define limit 10000000/size of integers array/

int main() { unsigned long long int i,j; int primes; begin = clock(); primes = malloc(sizeof(int)limit); for (i=2;i<limit;i++){ primes[i]=1;} for(i=2;i<limit;i++){ if(primes[i])} for (j=i;i*j<limit;j++){ end = clock();} printf("%f\n",(double)(end-begin)/CLOCKS_PER_SEC);

``````for (i=2;i<limit;i++){
if (primes[i])
}
printf("%dth prime=%dn", z++,i);
return 0;
``````

unipro4urs
91

 toggle preview community wiki:

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Question tags:

×56
×54
×13
×1

question asked: 07 Dec '16, 03:12

question was seen: 967 times

last updated: 20 Dec '16, 02:11