Cales - ComProg2 - Activity 6
Cales - ComProg2 - Activity 6
Cales
ICT 11 - 1
Activity 6
1.
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */
cout<<"--------------------------------"<<endl;
cout<<"Programmer's Name: Rose Mae D. Cales";
return 0;
}
2.
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */
cout<<"\n\t\tSum = "<<sum<<endl;
cout<<"\n--------------------------------"<<endl;
cout<<"Programmer's Name: Rose Mae D. Cales";
return 0;
}
3.
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */
int num;
if (num<=0){
cout<<"\n\tInvalid. Please input a positive integer.";
}
cout<<"___________________________________________________________________";
cout<<" "<<endl;
cout<<"\n\t\tThe multiplication table of "<<num<<endl;
for (int i=1; i<=10; ++i){
cout<<"\n\t"<<num<<" x "<<i<<" = "<<num*i<<endl;
}
cout<<"\n--------------------------------"<<endl;
cout<<"Programmer's Name: Rose Mae D. Cales";
return 0;
}
4.
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */
int num;
int f=1;
cout<<"\n--------------------------------"<<endl;
cout<<"Programmer's Name: Rose Mae D. Cales";
return 0;
}
5.
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */
cout<<"\n--------------------------------"<<endl;
cout<<"Programmer's Name: Rose Mae D. Cales";
return 0;
}
6.
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */
int n, rn=0;
cout<<"\n\t\t\tReveresed Numbers"<<endl;
cout<<"\n\t\tEnter an integer: ";
cin>> n;
while (n!=0){
rn=(rn*10)+(n%10);
n/=10;
}
cout<<"\n--------------------------------"<<endl;
cout<<"Programmer's Name: Rose Mae D. Cales";
return 0;
}
7.
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */
do{
cin>>n;
if (n%2==0){
sumeven+=n;
} else {
sumodd+=n;
}
} while (n!=0);
cout<<"\n--------------------------------"<<endl;
cout<<"Programmer's Name: Rose Mae D. Cales";
return 0;
}
8.
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */
cout<<"\n\t\t\tPrime Numbers"<<endl;
cout<<"\n\t\tEnter a positive integer: ";
cin >> number;
if (number <= 1) {
isPrime = false;
} else {
for (int i = 2; i * i <= number; ++i) {
if (number % i == 0) {
isPrime = false;
break;
}
}
}
if (isPrime) {
cout<<"\t\t"<<number<<" is a prime number."<<endl;
} else {
cout<<"\t\t"<<number<<" is not a prime number." <<endl;
}
cout<<"\n--------------------------------"<<endl;
cout<<"Programmer's Name: Rose Mae D. Cales";
return 0;
}
9.
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */
char choice;
int number1, number2;
int sum;
do {
cout << "\n\t\tEnter the first number: ";
cin >> number1;
cout << "\n\t\tThe sum of " << number1 << " and " << number2 << " is: " << sum <<endl;
cout << "\n\t\t\tDo you want to perform the operation again? (Y/N): ";
cin >> choice;
} while (choice == 'Y' || choice == 'y');
cout<<"\n--------------------------------"<<endl;
cout<<"Programmer's Name: Rose Mae D. Cales";
return 0;
}