int a[100];
int sum = 0;
for(int i = 0; i < 100; ++i) {
cin >> a[i];
sum += a[i];
}
and
int sum = 0;
for(int i = 0; i < 100; ++i) {
int val;
cin >> val;
sum += val;
}
My doubt is whether both the code snippets consume same amount of memory ?
Thanks in advance!
Edit : I don't understand why it's getting downvoted despite being a valid doubt.
Of course not.
You use an array in the first code so it'll consume more memory than the second one.