Write a program that asks the user to type 10 integers and writes the sum of these integers. Use either while or do-while or for loop. Start with a pseudocode and flowchart.
Flowchart
C++ Program
#include<iostream.h>
int main(void)
{
int n;
int sum =0;
int counter = 1;
while(counter <=10)
{
cout<<"sila masukkan no ";
cin>>n;
sum = sum +n;
counter = counter +1;
}
cout<<"Hasil tambah 10 nombor ialah : "<<sum;
return 0;
}
No comments:
Post a Comment