#include "stdio.h"
int main()
{
int n,i=0;
scanf("%d",&n);
while(n!=0)
{
if((1&n)!=0)
i++;
n>>1;
}
printf("%d",i);
}
Related Links :
History Of C..
In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.
My 1st Program...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}
Next Step...
#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");
printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");
getch ();
}
no output is coming
ReplyDeletemakes only small change in second last statement is n >>= 1 ;it gives an output
Deletewhat does this program do???
ReplyDeleteprogram to implement bitwise operators
ReplyDelete#include
#include
int disp(int x);
void main()
{
int i,j,m,n,w,a,b=12;
clrscr();
do
{
printf("enter any two numbers\n");
scanf("%d%d",&i,&j);
printf("1:one's complement\n2:left shift\n3:right shift\n4:AND\n5OR\n6:XOR\n7:end");
printf("\nenter ur choice");
scanf("%d",&n);
switch(n)
{
case 1:
{
printf("1's complement operation\n");
m=~i;
n=~j;
printf("1's complement of %d is :\t",i);
disp(m);
printf("1's complement of %d is :\t",j);
disp(n);
break;
}
case 2:
{
printf("right shift operation");
for(a=0;a<=3;a++)
{
m=i>>a;
printf("%d right shift of %d gives\n",i,a);
disp(m);
n=j>>a;
printf("\n%dright shift gives",j,a);
disp(n);
}
break;
}
case 3:
{
printf("left shift operation\n ");
for(a=0;a<=3;a++)
{
m=i<=0;p--)
{
s=i<<p;
q=x<<s;
(q==0?printf("0")|printf("1"));
}
}