Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

C++ Program to Print Number

1.
Entered by User
#include <iostream>

int main()
{
int broj;

std::cout<<"Unesite broj: ";


std::cin>>broj;

std::cout<<"Unijeli ste broj "<<broj;

return 0;
}

2. C++Program to Find Quotient


and Remainder
#include <iostream>

int main()
{
int broj1,broj2;

std::cout<<"Unesite dva broja: ";


std::cin>>broj1>>broj2;

double kolicnik;
kolicnik =broj1/broj2;

int ostatak;
ostatak =broj1%broj2;

std::cout<<"Kolinik je "<<kolicnik<<std::endl<<"Ostatak je "<<ostatak;


return 0;
}

3. C++
Program to Swap Two
Numbers
#include <iostream>

int main()
{
int broj1,broj2;

std::cout<<"Unesite dva broja: ";


std::cin>>broj1>>broj2;

int temp;

temp=broj1;
broj1=broj2;
broj2=temp;

std::cout<<"Prvi broj nakon zamjene je "<<broj1<<std::endl;


std::cout<<"Drugi broj nakon zamjene je "<<broj2<<std::endl;

return 0;
}

C++ Program to Check Whether


4.
Number is Even or Odd
#include <iostream>

int main()
{
int broj;
std::cout<<"Unesite broj: ";
std::cin>>broj;

if(broj%2==0)
{
std::cout<<"Broj je paran";
}
else
std::cout<<"Broj je neparan";

return 0;
}

You might also like