Pascal Odd or Even Number Program
Here is the source code.
program oddevennumber;
uses crt;
var angka,nomor: integer;
begin
clrscr;
writeln;
writeln('............................PROGRAM ODD & EVEN NUMBER...........................');
{Input}
writeln;writeln;
write(' Input a number: ');readln(angka);
writeln;
writeln('==============================');
{The Formula}
nomor:=angka mod 2;
{Range}
if (nomor=0) then
write(' ',angka,' IS EVEN NUMBER ')
else
write(' ',angka,' IS ODD NUMBER ');
readln;
write('==============================');
readln;
end.
Odd Number Program Using For Looping in C++
#include <iostream>
using namespace std;
int main()
{
int limit;
cout<<"--------------------------------\n";
cout<<" Input maxiumum number= ";
cin>>limit;
cout<<"================================\n";
for (int i=1;i<=limit;i++)
{
if(i%2==1)
{
cout<<" "<<i;
}
}
return 0;
}