Program menentukan Bilangan Ganjil Genap Dengan metode for C++

#include<stdio.h>
#include<iostream>
using namespace std;
int ganjil(int n);
int genap(int a);
int main()
{
int i;
cout<<“Ganjil :”;
for (i=1; i<=35;i++)
{
ganjil(i);
}
cout<<endl;
cout<<“Genap :”;
for (i=1; i<=35;i++)
{
genap(i);
}
cout<<endl;
}
int ganjil(int n)
{
if(n%2!=0)
{
cout<<n<<” “;
}
}
int genap(int a)
{
if(a%2==0)
{
cout<<a<<” “;
}
}

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s