list of c programs below: c program to convert decimal number to binary using functions, c program to convert decimal number to binary without functions

To convert decimal number to binary is divide the decimal number with 2 at each step and take remainders.

eg To convert decimal number 10 to binary

2 __| 2__

2 __| 1 – 0 __

__| 0 – 1__

here 1’s & 0’s are are remainders

Now combine all remainders serially from down to up i.e __10 __ This is binary number of 2 (decimal )

Convert decimal number to binary program logic: Enter decimal number n, divide n by 2 ( since binary ) and save remainder in array and quotient in n repeat until n is greater than zero.

## Write a C program to convert decimal number to binary number using while loop

Write a C program to convert decimal number to binary using while loop

#include <stdio.h>

void main()

{

int i=0,n,b[100];

printf(“\n OUTPUT: C program for converting decimal number to binary number”);

printf(“\nEnter decimal number: \n”;

scanf(“%d”,&n);

while (n>0)

{

b[i]=n%2;

n=n/2;

i++;

}

printf(“\nBinary is: “);

while(i>0)

{

printf(b[i]);

i–;

}

}

OUTPUT: C program for converting decimal number to binary number

Enter decimal number:2

Binary is: 10

## write a program to convert decimal number to binary number using for loop

Write a C program to convert decimal number to binary number using for loop

#include <stdio.h>

void main()

{

int i=0,n,a[100];

printf(“\n OUTPUT: C program for converting decimal number to binary number”);

printf(“\nEnter decimal number: \n”;

scanf(“%d”,&n);

for(;n>0;n=/2 )

{

a[i]=n%2;

i++;

}

printf(“\nBinary is: “);

while(i>0)

{

printf(a[i]);

i–;

}

}

OUTPUT:

OUTPUT: C program for converting decimal number to binary number

Enter decimal number:3

Binary is: 11

## Write a C program to convert decimal number to binary number using functions

Write a C program to convert decimal number to binary number using functions

#include <stdio.h>

void main()

{

int i=0,n,b[100];

printf(“\n OUTPUT: C program for converting decimal number to binary number”);

printf(“\n Enter decimal number: \n”);

scanf(“%d\n”,&n);

b=Dec_To_Bin(n);

printf(“The Binary value of decimal number %d is: \n”, n);

while(b[i]!=’\0′)

{

i++;

}

while(i>=0)

{

printf(“%d”, b[i]);

i–;

}

}

int[] Dec_To_Bin(int num)

{

int i=0, Bin[100];

while (num>0)

{

Bin[i]=num%2;

num=num/2;

i++;

}

return Bin[100];

}

OUTPUT:

OUTPUT: C program for converting decimal number to binary number

Enter decimal number:2

Binary is: 10

Why do we need to convert decimal number to binary?

The term binary has is the base for design of any logical circuit. TO represent a number or an alphabet or an operation or a screen element in any electronic circuit binary representation is used. A human understandable decimal number is used or stored in any electronic circuit in binary format

## Other programs:

Static variable scope

Register variable scope

External variable scope

Automatic variable scope

amicable number

Prime number

Perfect number

Palindrome number

Strong number

Find Factorial

Biggest Number

Average of n numbers

convert decimal number to octal

decimal number to hexadecimal

decimal number to binary

simple interest

compound interest

Add sparce matrices

Add matrices

file copying

Palindrome string

Reverse string

String length

Replace characters in string

substring or not using arrays

First occurrence of character in string

Last occurrence of character in string

Convert to uppercase

Convert to lowercase

Concatenate strings

Compare strings

Generate Employee payslips

Count students scoring marks>50%

convert weight into grams