Tuesday, 31 May 2016
#include<iostream.h>
#include<conio.h>
void Count(int arr[], int num);
void main()
{
clrscr();
int n, num[50];
cout<<"How many numbers you want to enter: ";
cin>>n;
for(int i=0; i<n; i++)
{
cout<<"Enter number: ";
cin>>num[i];
}
Count(num , n);
getch();
}
void Count (int arr[], int num)
{
int even, odd, zero;
even = odd = zero = 0;
for(int i= 0; i<num; i++)
{
if(arr[i]%2 == 0 && arr[i]!= 0)
even++;
if(arr[i] %2 != 0)
odd++;
if(arr[i] == 0)
zero++;
}
cout<<"Total numbers of zeros entered: "<<zero<<endl;
cout<<"Total numbers of odds entered: "<<odd<<endl;
cout<<"Total numbers of evens entered: "<<even;
}
#include<conio.h>
void Count(int arr[], int num);
void main()
{
clrscr();
int n, num[50];
cout<<"How many numbers you want to enter: ";
cin>>n;
for(int i=0; i<n; i++)
{
cout<<"Enter number: ";
cin>>num[i];
}
Count(num , n);
getch();
}
void Count (int arr[], int num)
{
int even, odd, zero;
even = odd = zero = 0;
for(int i= 0; i<num; i++)
{
if(arr[i]%2 == 0 && arr[i]!= 0)
even++;
if(arr[i] %2 != 0)
odd++;
if(arr[i] == 0)
zero++;
}
cout<<"Total numbers of zeros entered: "<<zero<<endl;
cout<<"Total numbers of odds entered: "<<odd<<endl;
cout<<"Total numbers of evens entered: "<<even;
}
#include <iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,f,g,d[32],e[32]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
unsigned long int deci;
char ch;
cout<<"Enter binary number(maximum 32 digits):";
c = 31;
b = 0;
while ((ch = getch()) != '\r')
{
d[b] = int(ch)-48;
b++;
}
for(int w=(b-1); w>=0; w--)
{
e[c] = d[w];
c--;
}
deci =0;
g = 31;
for(f=0; f<32; f++)
{
deci += (pow(2,g)*e[f]);
g--;
}
cout<<"\n Decimal equivalent of binary number is : "<<deci;
getch();
}
#include<conio.h>
void main()
{
clrscr();
int a,b,c,f,g,d[32],e[32]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
unsigned long int deci;
char ch;
cout<<"Enter binary number(maximum 32 digits):";
c = 31;
b = 0;
while ((ch = getch()) != '\r')
{
d[b] = int(ch)-48;
b++;
}
for(int w=(b-1); w>=0; w--)
{
e[c] = d[w];
c--;
}
deci =0;
g = 31;
for(f=0; f<32; f++)
{
deci += (pow(2,g)*e[f]);
g--;
}
cout<<"\n Decimal equivalent of binary number is : "<<deci;
getch();
}
#include<iostream.h>
#include<conio.h>
void binary(unsigned long int decimal)
{
int remainder;
if(decimal <= 1)
{
cout<<decimal;
return;
}
remainder = decimal % 2;
binary(decimal >>1);
cout<< reminder;
}
void main()
{
unsigned long int num;
clrscr();
cout<<"Enter decimal";
cin>> num;
cout<<endl<<"Binary of "<<num<<" is ";
binary(num);
getch();
}