HELP

Can you help me figure out why the code wont display the value of req. It just displays the printf statement.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#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: ", req);
	getchar();
	getchar();

	return 0;
}
You forgot the %d in the printf statement for req
thanks
but why does it give me a really big number. I am supposed to get 150.
show me your new code please, it works fine over here: http://cpp.sh/3ugzn
Topic archived. No new replies allowed.