convert python code to c online

''' Program for identify the Bulk density, Particle density, Percent pore space in python (pore space cylinder method)'''
#Get the input via user interaction with the help of the variables w, v1, v1, v4
w=input('Enter the weight of the soil taken in grams:')
v1=input('Enter the volume of soil taken in ml:')
v2=input('Enter the volume of water added in ml:')
v4=input('Enter the volume of soil water at the end of the experiment in ml:')#calculation for soil+water, pore space volume
v3=float(v1)+float(v2)
v5=float(v3)-float(v4)#calculation for bulk density, particle density, pore space
bd=float(w)/float(v1)
pd=float(w)/(float(v1)-float(v5))
pps=(float(v5)/float(v1))*100  #print the soil+water, pore space volume, bulk density, particle density, pore space
print("volume of soil+water:",v3)
print(" pore space volume:",v5)
print("bulk density milligram per meter cube:",bd)
print("particle density:",pd)
print("percent pore space(in percentage):",pps)

4
6

                                    ALGORITMO
DECLARE num[5,4] NUMÉRICO
 num_aux, i, j, k, l, m, n, lin, col NUMÉRICO
PARA i ← 1 ATÉ 5 FAÇA
INÍCIO
PARA j ← 1 ATÉ 4 FAÇA
INÍCIO
LEIA num_aux
IF i = 1 E j = 1
ENTÃO num[i, j] ← num_aux
SENÃO INICIO
 k ← 1
 l ← 1
 ENQUANTO num[k, l] < num_aux E (k  i OU l  j) FAÇA
 INÍCIO
 l ← l + 1
 SE l > 4
 ENTÃO INÍCIO
 k ← k + 1
 l ← 1
 FIM
 FIM
 m ← i;
 n ← j;
 ENQUANTO m  k OU n  l FAÇA
 INÍCIO
 SE n-1 < 1 ENTÃO
 INÍCIO
 lin ← m-1
 col ← 4
 FIM
 SENÃO INÍCIO
 lin ← m
 col ← n-1
 FIM
 num[m][n] ← num[lin][col]
 n ← n-1
 SE n < 1
 ENTÃO INÍCIO
 n ← 4
 m ← m-1
 FIM
 FIM
 num[k][l] ← num_aux
 FIM
FIM
FIM
PARA i ← 1 ATÉ 5 FAÇA
INÍCIO
PARA j ← 1 ATÉ 4 FAÇA
INÍCIO
ESCREVA “Elemento da posição “, i, “-”, j, “ = “, num[i][j]
FIM
FIM
FIM_ALGORITMO.

4 (6 Votes)
0
3.5
2

                                    option=int(input('Press 1 for generating hamming code  \nPress 2 for finding error in hamming code\n\t Enter your choice:--\n'))

if(option==1):  # GENERATE HAMMING CODE
    print('Enter the data bits')
    d=input()
    data=list(d)
    data.reverse()
    c,ch,j,r,h=0,0,0,0,[]

    while ((len(d)+r+1)>(pow(2,r))):
        r=r+1

    for i in range(0,(r+len(data))):
        p=(2**c)

        if(p==(i+1)):
            h.append(0)
            c=c+1

        else:
            h.append(int(data[j]))
            j=j+1

    for parity in range(0,(len(h))):
        ph=(2**ch)
        if(ph==(parity+1)):
            startIndex=ph-1
            i=startIndex
            toXor=[]

            while(i<len(h)):
                block=h[i:i+ph]
                toXor.extend(block)
                i+=2*ph

            for z in range(1,len(toXor)):
                h[startIndex]=h[startIndex]^toXor[z]
            ch+=1

    h.reverse()
    print('Hamming code generated would be:- ', end="")
    print(int(''.join(map(str, h))))


elif(option==2): # DETECT ERROR IN RECEIVED HAMMING CODE
    print('Enter the hamming code received')
    d=input()
    data=list(d)
    data.reverse()
    c,ch,j,r,error,h,parity_list,h_copy=0,0,0,0,0,[],[],[]

    for k in range(0,len(data)):
        p=(2**c)
        h.append(int(data[k]))
        h_copy.append(data[k])
        if(p==(k+1)):
            c=c+1
            
    for parity in range(0,(len(h))):
        ph=(2**ch)
        if(ph==(parity+1)):

            startIndex=ph-1
            i=startIndex
            toXor=[]

            while(i<len(h)):
                block=h[i:i+ph]
                toXor.extend(block)
                i+=2*ph

            for z in range(1,len(toXor)):
                h[startIndex]=h[startIndex]^toXor[z]
            parity_list.append(h[parity])
            ch+=1
    parity_list.reverse()
    error=sum(int(parity_list) * (2 ** i) for i, parity_list in enumerate(parity_list[::-1]))
    
    if((error)==0):
        print('There is no error in the hamming code received')

    elif((error)>=len(h_copy)):
        print('Error cannot be detected')

    else:
        print('Error is in',error,'bit')

        if(h_copy[error-1]=='0'):
            h_copy[error-1]='1'

        elif(h_copy[error-1]=='1'):
            h_copy[error-1]='0'
            print('After correction hamming code is:- ')
        h_copy.reverse()
        print(int(''.join(map(str, h_copy))))

else:
    print('Option entered does not exist')

3.5 (2 Votes)
0
3.83
6
Bakery 70 points

                                    # Raw Package
import numpy as np
import pandas as pd

#Data Source
import yfinance as yf

#Data viz
import plotly.graph_objs as go

#Interval required 1 minute
data = yf.download(tickers='UBER', period='1d', interval='1m')

#declare figure
fig = go.Figure()

#Candlestick
fig.add_trace(go.Candlestick(x=data.index,
                open=data['Open'],
                high=data['High'],
                low=data['Low'],
                close=data['Close'], name = 'market data'))

# Add titles
fig.update_layout(
    title='Uber live share price evolution',
    yaxis_title='Stock Price (USD per Shares)')

# X-Axes
fig.update_xaxes(
    rangeslider_visible=True,
    rangeselector=dict(
        buttons=list([
            dict(count=15, label="15m", step="minute", stepmode="backward"),
            dict(count=45, label="45m", step="minute", stepmode="backward"),
            dict(count=1, label="HTD", step="hour", stepmode="todate"),
            dict(count=3, label="3h", step="hour", stepmode="backward"),
            dict(step="all")
        ])
    )
)

#Show
fig.show()

3.83 (6 Votes)
0
3.8
10
Potluck 110 points

                                    importmath #Get the inputs via user interaction with help of variables Na ,Ca ,Mg
Na=input ('Enter the value of Na+:')
Ca=input ('Enter the value of Ca2:')
Mg=input ('Enter the value of Mg2+:')#Calculation based on the formula
sar=float(Na)/(math.sqrt((float(Ca)+float(Mg))/2))
#Print the SAR
print("SAR:",sar)#Control flow statement for remarks
if sar>=0and sar<=10:
print("water class=s1 Low sodium hazard Remarks: Little or no hazard")
elif sar>=10and sar<=18:
print("water class=s2 Medium sodium hazard  Remarks: Appreciable hazard but can be used with appropriate management techniques")
elif sar>=18and sar<=26:
print("water class=s3 high sodium hazard  Remarks: Unsatisfactory for most of the crops")
elif sar>=26:
print("water class=s4 very high sodium hazard  Remarks: Not suitable")

3.8 (10 Votes)
0
0
3

                                    x = 5
y = 10
print(x + y)

0
0
4
2
Ponysopher 90 points

                                    def main(str1, str2):
    m = len(str1)
    n = len(str2)
    j = 0    
    i = 0
    while j < m and i < n:
        if str1[j] == str2[i]:
            j = j+1
        i = i + 1
    return j == m
str2 = str(input())
N = int(input())
for i in range(N):
    str1 = str(input())
    if main(str1, str2):
        print("POSITIVE") 
    else:
        print( "NEGATIVE")

4 (2 Votes)
0
4
9
JustOneMan 95 points

                                    #Get the input via user interaction with the help of the variables w, v1, v1, v4
w=input('Enter the weight of the soil taken in grams:')
v1=input('Enter the volume of soil taken in ml:')
v2=input('Enter the volume of water added in ml:')
v4=input('Enter the volume of soil water at the end of the experiment in ml:')#calculation for soil+water, pore space volume
v3=float(v1)+float(v2)
v5=float(v3)-float(v4)#calculation for bulk density, particle density, pore space
bd=float(w)/float(v1)
pd=float(w)/(float(v1)-float(v5))
pps=(float(v5)/float(v1))*100  #print the soil+water, pore space volume, bulk density, particle density, pore space
print("volume of soil+water:",v3)
print(" pore space volume:",v5)
print("bulk density milligram per meter cube:",bd)
print("particle density:",pd)
print("percent pore space(in percentage):",pps)

4 (9 Votes)
0
4.1
10
Kenneth K. 100 points

                                    # cook your dish here
tc = int(input())
for _ in range(tc):
    c = 0
    n = int(input())
    n = pow(2,n)
    for x in range(0,n):
        a = x ^ (x+1)
        b = (x+2) ^ (x+3)
        if(a==b):
            c+=1
    print(c)

4.1 (10 Votes)
0
4
5

                                    ''' Program for identify the Bulk density, Particle density, Percent pore space in python (pore space cylinder method)'''
#Get the input via user interaction with the help of the variables w, v1, v1, v4
w=input('Enter the weight of the soil taken in grams:')
v1=input('Enter the volume of soil taken in ml:')
v2=input('Enter the volume of water added in ml:')
v4=input('Enter the volume of soil water at the end of the experiment in ml:')#calculation for soil+water, pore space volume
v3=float(v1)+float(v2)
v5=float(v3)-float(v4)#calculation for bulk density, particle density, pore space
bd=float(w)/float(v1)
pd=float(w)/(float(v1)-float(v5))
pps=(float(v5)/float(v1))*100  #print the soil+water, pore space volume, bulk density, particle density, pore space
print("volume of soil+water:",v3)
print(" pore space volume:",v5)
print("bulk density milligram per meter cube:",bd)
print("particle density:",pd)
print("percent pore space(in percentage):",pps)

4 (5 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source