Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binary_decimal #53

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Concatination_ofString_Python
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Str1=input("Enter the String1 to be concatenated")
Str2=input("Enter the String2 to be concatenated")
print(Str1+Str2)
3 changes: 3 additions & 0 deletions Concatination_ofStrings_Python
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Str1=input("Enter the String1 to be concatenated")
Str2=input("Enter the String2 to be concatenated")
print(Str1+Str2)
19 changes: 19 additions & 0 deletions binary_decimal
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>

void main()
{
int num, binary_val, decimal_val = 0, base = 1, rem;

printf("Enter a binary number(1s and 0s) \n");
scanf("%d", &num); /* maximum five digits */
binary_val = num;
while (num > 0)
{
rem = num % 10;
decimal_val = decimal_val + rem * base;
num = num / 10 ;
base = base * 2;
}
printf("The Binary number is = %d \n", binary_val);
printf("Its decimal equivalent is = %d \n", decimal_val);
}
42 changes: 42 additions & 0 deletions factorial
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import java.util.*;
class FCTRL{
static int product(int x,int arr[],int len)
{
int carry=0;
for(int i=0;i<len;i++)
{
int prod=arr[i]*x+carry;
arr[i]=prod%10;
carry=prod/10;
}
while(carry!=0)
{
arr[len]=carry%10;
carry=carry/10;
len++;
}
return len;
}
static void factorial(int n)
{
int arr[]=new int[5000];
arr[0]=1;
int len=1;
for(int x=2;x<=n;x++)
len=product(x,arr,len);
for(int i=len-1;i>=0;i--)
System.out.println(arr[i]);
}
public static void main(String args[])
{
try{
Scanner sc=new Scanner(System.in);
int test=sc.nextInt();
for(int i=1;i<=test;i++)
{
int a=sc.nextInt();
factorial(a);
}}
catch(exception e){
return ;}
}}