long int binary(int);
long int binary(int num){
int binarynum=0,temp=1;
while(num){
int last = num%2;
num = num/2;
binarynum = binarynum + last*temp;
temp = temp * 10;
}
return binarynum;
}
int main (int argc, char *argv[]){
if(argc>3){
cout<<"\nInvalid Input";
}
else{
int num1 = atoi(argv[1]);
int num2 = atoi(argv[2]);
int sum = num1+num2;
long int binaryNum = binary(sum);
cout<<binaryNum;
}
return 0;
}
n1,n2=map(int,input(“Enter the two number n1 and n2:\n”).split(” “))
sum=n1+n2
x=bin(sum)
print(f”The addition of {n1} and {n2} is:{sum} and its binary representation is {x}”)
public class NewClass6 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int sum=a+b;
System.out.println(Integer.toBinaryString(sum));
}
}
int main(int argv,char* argc[])
{
int sum,i=0;
int rem[100];
if(argv==1)
printf(“Invalid Input “);
else
sum=atoi(argc[1])+atoi(argc[2]);
while(sum>0){
rem[i]=sum%2;
sum=sum/2;
i++;
}
for(int j=0;j<i;j++)
printf("%d",rem[j]);
}
#include
using namespace std;
long int binary(int);
long int binary(int num){
int binarynum=0,temp=1;
while(num){
int last = num%2;
num = num/2;
binarynum = binarynum + last*temp;
temp = temp * 10;
}
return binarynum;
}
int main (int argc, char *argv[]){
if(argc>3){
cout<<"\nInvalid Input";
}
else{
int num1 = atoi(argv[1]);
int num2 = atoi(argv[2]);
int sum = num1+num2;
long int binaryNum = binary(sum);
cout<<binaryNum;
}
return 0;
}
#include
int main()
{
int i,j,k,l,x,y,r,arr[20],count=0;
printf(“enter numbers which needs to be added\n”);
scanf(“%d%d”,&k,&l);
x=k+l;
for(i=0;x>0;++i)
{
arr[i]=x%2;
x=x/2;
count++;
}
for(j=count-1;j>=0;–j)
printf(“%d “,arr[j]);
return 0;
}
#include
int main()
{
int i,j,k,l,x,y,r,arr[20],count=0;
printf(“enter numbers which needs to be added\n”);
scanf(“%d%d”,&k,&l);
x=k+l;
for(i=0;i<=20;++i)//454
{
arr[i]=x%2;
x=x/2;//227
count++;
if(x=0;–j)
printf(“%d “,arr[j]);
return 0;
}
#include
#include
int main(int argc, char *argv[])
{
int sum;
if(argc == 1){
printf(“enter number”);
}
else{
int i,j,r,a[10];
sum = atoi(argv[1]) + atoi(argv[2]);
printf(“sum %d\n”,sum);
for(i=0;sum>0;i++)
{
r = sum%2;
a[i] = r;
sum = sum/2;
}
printf(“binary format is\n”);
for(j=i-1;j>=0;j–)
{
printf(“%d”,a[j]);
}
}
return 0;
}
#Addition of 2 numbers and printing the result in binary
a,b=map(int, input().split(” “))
sum=a+b
x=bin(sum).replace(“0b”,” “)
print(“binary Addition is :”,x)
/* using c program*/
#include
void main()
{
int a,b,c,rem,arr[100],count=0;
printf(“Enter two numbers \n”);
scanf(“%d %d”,&a,&b);
c=a+b;
printf(“Addition of commandn line is %d”,c);
while(c)
{
rem=c%2;
arr[count]=rem;
count++;
c=c/2;
}
printf(“\nBinary Representation “);
while(count)
{
printf(“%d”,arr[count-1]);
count–;
}
}
//Addition of 2 numbers and printing the result in binary Using Command Line Programming
#include
void binary(int,int);
int main(){
int a,b,res;
scanf(“%d%d”,&a,&b);
binary(a+b,2);
}
void binary(int n,int base){
int rem;
if(n==0)
return;
rem = n%base;
binary(n/base,base);
printf(“%d”,rem);
}
#python
n1,n2=map(int,input(“Enter the two number n1 and n2:\n”).split(” “))
sum=n1+n2
x=bin(sum)
print(f”The addition of {n1} and {n2} is:{sum} and its binary representation is {x}”)
public class NewClass6 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int sum=a+b;
System.out.println(Integer.toBinaryString(sum));
}
}
import sys
a=sys.argv[1:]
k=max(a)
while(max(a)==k):
a.remove(max(a))
print(max(a))
#include
#include
int main(int argc,char *argv[])
{
if(argc0)
{
rem=sum%2;
binary+=rem*base;
base=base*10;
sum=sum/2;
}
printf(“%d”,binary);
return 0;
}
}