convert python code to c online

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.

3.7
12
Awgiedawgie 440215 points

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

3.7 (10 Votes)
0
3.6
10
Awgiedawgie 440215 points

                                    ''' 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(&quot;volume of soil+water:&quot;,v3)
print(&quot; pore space volume:&quot;,v5)
print(&quot;bulk density milligram per meter cube:&quot;,bd)
print(&quot;particle density:&quot;,pd)
print(&quot;percent pore space(in percentage):&quot;,pps)

3.6 (10 Votes)
0
0
6
Awgiedawgie 440215 points

                                    ''' 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(&quot;volume of soil+water:&quot;,v3)
print(&quot; pore space volume:&quot;,v5)
print(&quot;bulk density milligram per meter cube:&quot;,bd)
print(&quot;particle density:&quot;,pd)
print(&quot;percent pore space(in percentage):&quot;,pps)

0
0
4.11
9
Krish 100200 points

                                    ALGORITMO
DECLARE num[5,4] NUM&Eacute;RICO
 num_aux, i, j, k, l, m, n, lin, col NUM&Eacute;RICO
PARA i &larr; 1 AT&Eacute; 5 FA&Ccedil;A
IN&Iacute;CIO
PARA j &larr; 1 AT&Eacute; 4 FA&Ccedil;A
IN&Iacute;CIO
LEIA num_aux
IF i = 1 E j = 1
ENT&Atilde;O num[i, j] &larr; num_aux
SEN&Atilde;O INICIO
 k &larr; 1
 l &larr; 1
 ENQUANTO num[k, l] &lt; num_aux E (k  i OU l  j) FA&Ccedil;A
 IN&Iacute;CIO
 l &larr; l + 1
 SE l &gt; 4
 ENT&Atilde;O IN&Iacute;CIO
 k &larr; k + 1
 l &larr; 1
 FIM
 FIM
 m &larr; i;
 n &larr; j;
 ENQUANTO m  k OU n  l FA&Ccedil;A
 IN&Iacute;CIO
 SE n-1 &lt; 1 ENT&Atilde;O
 IN&Iacute;CIO
 lin &larr; m-1
 col &larr; 4
 FIM
 SEN&Atilde;O IN&Iacute;CIO
 lin &larr; m
 col &larr; n-1
 FIM
 num[m][n] &larr; num[lin][col]
 n &larr; n-1
 SE n &lt; 1
 ENT&Atilde;O IN&Iacute;CIO
 n &larr; 4
 m &larr; m-1
 FIM
 FIM
 num[k][l] &larr; num_aux
 FIM
FIM
FIM
PARA i &larr; 1 AT&Eacute; 5 FA&Ccedil;A
IN&Iacute;CIO
PARA j &larr; 1 AT&Eacute; 4 FA&Ccedil;A
IN&Iacute;CIO
ESCREVA &ldquo;Elemento da posi&ccedil;&atilde;o &ldquo;, i, &ldquo;-&rdquo;, j, &ldquo; = &ldquo;, num[i][j]
FIM
FIM
FIM_ALGORITMO.

4.11 (9 Votes)
0
4
11
Phoenix Logan 186120 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 (9 Votes)
0
4
2
Awgiedawgie 440215 points

                                    def main(str1, str2):
    m = len(str1)
    n = len(str2)
    j = 0    
    i = 0
    while j &lt; m and i &lt; 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(&quot;POSITIVE&quot;) 
    else:
        print( &quot;NEGATIVE&quot;)

4 (2 Votes)
0
0
4
Krish 100200 points

                                    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)&gt;(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&lt;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=&quot;&quot;)
    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&lt;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)&gt;=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')

0
0
4.57
7
Phoenix Logan 186120 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=&quot;15m&quot;, step=&quot;minute&quot;, stepmode=&quot;backward&quot;),
            dict(count=45, label=&quot;45m&quot;, step=&quot;minute&quot;, stepmode=&quot;backward&quot;),
            dict(count=1, label=&quot;HTD&quot;, step=&quot;hour&quot;, stepmode=&quot;todate&quot;),
            dict(count=3, label=&quot;3h&quot;, step=&quot;hour&quot;, stepmode=&quot;backward&quot;),
            dict(step=&quot;all&quot;)
        ])
    )
)

#Show
fig.show()

4.57 (7 Votes)
0
0
0
Phoenix Logan 186120 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(&quot;volume of soil+water:&quot;,v3)
print(&quot; pore space volume:&quot;,v5)
print(&quot;bulk density milligram per meter cube:&quot;,bd)
print(&quot;particle density:&quot;,pd)
print(&quot;percent pore space(in percentage):&quot;,pps)

0
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