- Joined
- Nov 12, 2013
- Posts
- 1,383
- Solutions
- 1
- Reaction
- 2,204
- Points
- 567
- Age
- 27
Mga bossing patulong naman dito pag code ng C++.
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter a Number: ";
cin >> n;
int i = 1;
while (i <= n) {
cout << i << endl;
++i;
}
sum = sum + n;
cout << endl;
cout << "The sum is: ";
system("PAUSE");
return 0;
}
Dapat ganito result:
Enter a Number: 5
1
2
3
4
5
The sum is: 15
-Paano po ma add yung loop na numbers po? Kapag nag entry po ako ng 3 dapat po ang sum ay 6 po.
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter a Number: ";
cin >> n;
int i = 1;
while (i <= n) {
cout << i << endl;
++i;
}
sum = sum + n;
cout << endl;
cout << "The sum is: ";
system("PAUSE");
return 0;
}
Dapat ganito result:
Enter a Number: 5
1
2
3
4
5
The sum is: 15
-Paano po ma add yung loop na numbers po? Kapag nag entry po ako ng 3 dapat po ang sum ay 6 po.