











Problem 18
Access Denied!
To view this page you have to login first
Login here -
Trivia
Did you know 1 million people use PrepInsta everyday?
To view this page you have to login first
Login here -
Did you know 1 million people use PrepInsta everyday?
#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;
}
}