Computer Science, asked by pm0049175payalmishra, 4 days ago

1) write a program to accept a decimal number and display it's in binary format.

2)Write a program to calculate the total number of zeros,positive and negative elements in the list
hint:-L1(23,4,56,-1,0,46,-8,-9,0,-11,31)
o/p:-no of zeros=2
:-no of positive no=6
:-no of negative no=4

Answers

Answered by r27272278
0

1) #include<stdio.h>

#include<stdlib.h>

int main(){

int a[10],n,i;

system ("cls");

printf("Enter the number to convert: ");

scanf("%d",&n);

for(i=0;n>0;i++)

{

a[i]=n%2;

n=n/2;

}

printf("\nBinary of Given Number is=");

for(i=i-1;i>=0;i--)

{

printf("%d",a[i]);

}

return 0;

}

Output :

Enter the number to convert: 5

Binary of Given Number is=101

Answered by namanrounak125
0

Answer:

1) This will work for python language printf("Enter the number to convert: ")

Similar questions