HELP

Why dont i get 150? I get a really big number.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h>

int main(){
	int i, req = 0;
	int R[] = { 10.00, 20.00, 30.00, 40.00, 50.00 };
	int *Ptr;
	Ptr = R;
   
	
	for (i = 0; i < 5; i++){
		printf("R[%d]=%d\n", i, R[i]);

		req += R[i];

	}
		printf(" The value of req is: %d ", &req);
	

	getchar();
	getchar();

	return 0;
}
it's because you print &req which returns the adress of req.
simply emit that &
printf(" The value of req is: %d ", req);

and please avoid making 2 posts.
Last edited on
huh? If i take out the printf it doesnt compute req like i need it to do.
no, no, don't take out the printf, just change the &reg to reg in the last printf statement
1
2
this: printf(" The value of req is: %d ", &req); // should be
that: printf(" The value of req is: %d ", req);
Last edited on
Topic archived. No new replies allowed.