- Joined
- Oct 24, 2021
- Posts
- 1,482
- Reaction
- 326
- Points
- 667
Problem Description: Susan was given a list of arbitrary numbers, she was tasked to display all the even numbers from the list.
Input Format: The line begins with an integer n indicating the number of integers m that follow which compromises a list.
Output Format: All even numbers from the list, each separated by a comma",".
2 <= n <= 100
-1000
Constraints: <= m <= 1000
Sample Input: 2 3 6 7
Output : 2, 6
Code ko(walang output ang problema ko huhu):
#include <iostream>
using namespace std;
int main() {
int n,m=0;
cout<< "Enter the number of number: ";
cin>>n;
if (2 <=n && n<= 100){
while (n>0){
if (1000 <=m && m<= 1000){
if (m%2==0){
cout<<m<<",";
}
}
m++;
n--;
}
}
return 0;
}
Input Format: The line begins with an integer n indicating the number of integers m that follow which compromises a list.
Output Format: All even numbers from the list, each separated by a comma",".
2 <= n <= 100
-1000
Constraints: <= m <= 1000
Sample Input: 2 3 6 7
Output : 2, 6
Code ko(walang output ang problema ko huhu):
#include <iostream>
using namespace std;
int main() {
int n,m=0;
cout<< "Enter the number of number: ";
cin>>n;
if (2 <=n && n<= 100){
while (n>0){
if (1000 <=m && m<= 1000){
if (m%2==0){
cout<<m<<",";
}
}
m++;
n--;
}
}
return 0;
}