#include <iostream>
usingnamespace std;
int main(){
int number = 0;
int sum = 0;
cout << "Enter how many numbers input : ";
cin >> number;
for( int i = 0 ; i <= number ; i ++ ){
sum += i;
}
cout << "Total : " << sum << endl;
system( "pause" );
return 0;
}
this a simple code that from question want me to do
it's not hard by i just can't really know how to write in pseudocode
Write the pseudocode that uses a loop to find the sum of the squares of all integers between 1 and n. What is the running time (Big-O) of your algorithm?
I know my Big-O is = O(n)
but can someone teach me how to writ pseudocode base on my program?
i know it's simple but for me hard caus ei not so familiar
Looks like you're just getting the sum. As far as writing pseudocode, I'd follow along with how 'Introduction to Algorithms' does it, unless told otherwise by your instructor.
If your input is 6, your output shouldn't be 1+2+3+4+5+6 BUT 1*1+2*2+3*3+4*4+5*5+6*6. Therefore in your pseudo code, your sum would be sum+=(iterator_value*iterator_value).