8.1. Ispis paranih i neparnih brojeva od 1 do n (test parnosti i neparnosti).
Listing programa:
//P08111008//
#include <iostream>
#include <cmath>
using namespace std;
main()
{
int i,n;
cout<<"Parni i neparni brojevi"<<endl;
cout<<"Do broja: "<<endl;
cin>>n;
for(i=1; i<=n; i++)
if(i % 2 == 0)
cout<<i<<" je paran"<<endl;
else
cout<<i<<" je neparan"<<endl;
system("PAUSE");
}
Ispis na ekranu:

Index
|