0% found this document useful (0 votes)
2 views3 pages

Programs

The document contains three programming exercises. The first program checks if five entered numbers are Pronic numbers, the second determines if a number is Odious or Evil based on its binary representation, and the third converts a decimal number to its binary equivalent. Each program is written in C++ and includes code snippets for implementation.

Uploaded by

tapanvety
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Programs

The document contains three programming exercises. The first program checks if five entered numbers are Pronic numbers, the second determines if a number is Odious or Evil based on its binary representation, and the third converts a decimal number to its binary equivalent. Each program is written in C++ and includes code snippets for implementation.

Uploaded by

tapanvety
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Programs done on 21-12-2024

1. WAP to enter 5 numbers then check and print if the numbers are
Pronic number or not.

#include <iostream.h>
#include <conio.h>

void main()
{
clrscr();
int n,i=1,fl,j;
cout<<"Enter 5 numbers : ";
while(i<=5)
{
cin>>n;
j=1;
fl=0;
while(j<n)
{
if(j*(j+1)==n)
{
cout<<n<<" is a Pronic number"<<endl;
fl=1;
break;
}
j++;
}
if(fl==0)
cout<<n<<" is not a Pronic number"<<endl;
i++;
}
getch();
}
2. WAP to enter a number then check and print if it is an Odious or Evil
number.

#include <iostream.h>
#include <conio.h>

void main()
{
clrscr();
int n,r,c=0,n1;
cout<<"Enter a number : ";
cin>>n;
n1=n;
while(n1>0)
{
r=n1%2;
if(r==1)
c++;
n1/=2;
}
if(c%2==1)
cout<<"It is an Odious number";
else
cout<<"It is an Evil number";
getch();
}
3. WAP to enter a number (Decimal) then convert and print it in Binary.

#include <iostream.h>
#include <conio.h>
#include <math.h>

void main()
{
clrscr();
int n,r,c=0,n1,b=0; //p=1;
cout<<"Enter a number : ";
cin>>n;
n1=n;
while(n1>0)
{
r=n1%2;
b=r*(int)pow(10,c)+b; //b=r*p+b;
c++; //p=p*10;
n1/=2;
}
cout<<"Binary equivalent : "<<b;
getch();
}

You might also like