#include <stdio.h>
#include "waqas.h"
int main()
{
inta,b,c,d,n,e;
printf("Enter 1 for add and 2 for convert\n\n");
scanf("%d" ,&e);
if(e==1)
{
printf("Enter four separate numbers\n");
scanf("%d%d%d%d" ,&a,&b,&c,&d);
printf("%d is the Sum\t" ,add(a,b,c,d));
}
else if(e==2)
{
printf("Enter a decimal number to convert in binary\n");
scanf("%d" ,&n);
printf("The binary equilant is = %d\n" ,convert(n));
}
else
{
printf("Error !!!!!!\n");
}
return 0;
}
#include <stdio.h>
#include <math.h>
int add(int a ,int b,int c, int d)
{
int sum;
sum=a+b+c+d;
return sum;
}
int convert(int n)
{
intremainder,bin=0,j=0;
while(n>0)
{
remainder=n%2;
bin=bin+remainder*pow(10,(double)j);
j++;
n=n/2;
}
return bin;
}
make a function to add integers |
make a function to convert decimal number to binary number |