Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
BSIT 1202
3. Area of circle
Step 1: Start
Step 2: Input value of radius (r)
Step 3: Calculate area using pi*r ²
Step 4: Output area
Step 5: End
4. Volume of sphere
Step 1: Start
Step 2: Input value of radius (r)
Step 3: Calculate volume of sphere using 4/3*pi*r ³
Step 4: Output volume
Step 5: End
Create a program.
1. Write a program in C++ to find the first 10 natural numbers.
#include <iostream>
using namespace std;
int main()
{
int x;
cout << "The natural numbers are: \n";
for (x = 1; x <= 10; x++)
{
cout << x << " ";
}
cout << endl;
return 0;
}
3. Write a program in C++ to display n terms of natural number and their sum.
#include<iostream>
using namespace std;
int main()
{
int b, x, sum=0;
cout<<"Input a number of terms: ";
cin>>x;
for (int b=1; b <= x; b++)
{
cout << b << " ";
sum = sum + b;
}
cout << endl;
cout << "The sum of the natural numbers are " << sum << endl;
return 0;
}
int main()
{
int x, b, sum = 0;
cout << "Enter the value for the nth term: ";
cin >> b;
Multiplication Table
#include<iostream>
using namespace std;
int main()
{
cout << "Multiplication table" << endl;
cout << " 1 \t2\t3\t4\t5\t6\t7\t8\t9" << endl;
cout << "" << endl;