0

In a while loop what is the difference between int num=1;. and int number; ?

#include <iostream> using namespace std; int main() { int num = 1; int number; int total = 0; while (num <= 5) { cin >> number; total += number; num++; } cout << total << endl; return 0; }

2nd Mar 2017, 2:45 PM
RAHUL PATIDAR
RAHUL PATIDAR - avatar
1 Answer
+ 2
int num =1 is saying that you want memory to store an integer with the value of 1 and its name will be 'num' int number is saying that you want memory to be reserved for an integer that will be given later but its name is going to be 'number'
2nd Mar 2017, 2:50 PM
Jason Hoffman
Jason Hoffman - avatar