c++ code to python code converter online code example

Example 1: c++ code to python code converter online

void decrypt(string &text, string &key){
	for(size_t i=0;i<text.length()-1;i++){
		for (int j=0;j<26;j++){
			if (text[i]==key[j]){
				text[i]=j+97;
				break;
			}
		}
	}
}

Example 2: c++ code to python code converter online

void decrypt(string &text, string &key){
	for(size_t i=0;i<text.length()-1;i++){
		for (int j=0;j<26;j++){
			if (text[i]==key[j]){
				text[i]=j+97;
				break;
			}
		}
	}
}

Example 3: c++ code to python code converter online

#include<iostream>
#include<math.h>
#define vL 0.4
using namespace std;
struct generator
{
    float IL,theat,Pout;
};
typedef struct generator GENERATOR;
int main()
{
    int i=0,n;
    float sum=0,avg,low,high,il,theat;
    cout<<"Enter the value for 'n' : ";
    cin>>n;
    GENERATOR g[n];
    
    while(i<n)
    {
        cout<<"Enter Voltage and Current";
        cin>>il>>theat;
        if(il>0&&theat>=35&&theat<=45){
        g[i].IL=il;
        g[i].theat=theat;
        g[i].Pout=sqrt(3)*il*cos(theat);
        cout<<g[i].Pout;
        
        if(i==0)
        {
            low=g[i].Pout;
            high=g[i].Pout;
        }
        ++i;
        }else
            cout<<"\nEnter Valid data(il>0 and theat>=-35 and theat<=45)";
    }
    i=1;
    while(i<n)
    {
        if(low>g[i].Pout)
            low=g[i].Pout;
        if(high<g[i].Pout)
            high=g[i].Pout;
        sum+=g[i].Pout;
        i++;
    }
    avg=sum/n;
    cout<<"\nThe Lowest Output Power :"<<low;
    cout<<"\nThe highest Output Power :"<<high;
    cout<<"\nThe Average Output Power :"<<avg;
    
    
}
 OUTPUT

Example 4: c++ code to python code converter online

print('hello')

Example 5: c++ code to python code converter online

#include <iostream>
using namespace std;

int main()
{
    char gender;
    double bodyweight, wrist, waist, hip, forearm, B, bodyfat, bfPercentage, A1, A2, A3, A4, A5;

    bodyfat = bodyweight - B;
    bfPercentage = (bodyfat * 100) / bodyweight;

    cout << "Input gender (m/f): ";
    cin >> gender;

    switch (gender)
    {
    case 'F':
    case 'f':
        cout << "Enter body weight: ";
        cin >> bodyweight;
        cout << "Enter wrist measurement (at fullest point): ";
        cin >> wrist;
        cout << "Enter waist measurement (at navel): ";
        cin >> waist;
        cout << "Enter hip measurement (at fullest point): ";
        cin >> hip;
        cout << "Enter forearm measurement (at fullest point): ";
        cin >> forearm;

        A1 = (bodyweight * 0.723) + 8.987;
        A2 = (wrist) / 3.140;
        A3 = (waist) * 0.157;
        A4 = (hip) * 0.249;
        A5 = (forearm) * 0.434;

        B = A1 + A2 - A3 - A4 + A5;

        cout << "Your body fat is: " << bodyfat << endl
             << "Body fat percentage: " << bfPercentage << "%";
             break;

    case 'M':
    case 'm':
        cout << "Enter body weight: ";
        cin >> bodyweight;
        cout << "Enter wrist measurement (at fullest point): ";
        cin >> wrist;

        A1 = (bodyweight * 1.082) + 94.42;
        A2 = wrist * 4.14;

        B = A1 - A2;

        cout << "Your body fat is: " << bodyfat << endl
             << "Body fat percentage: " << bfPercentage << "%";
             break;

    default:
        cout << "Invalid gender.";
    }

    return 0;
}

Example 6: c++ code to python code converter online

#include<bits/stdc++.h>
#include <iostream>

using namespace std;


struct n{
    int d;
    struct n*next;
    };

void push(struct n**headref, int new_d)
{
    struct n* new_node=new n;
    new_node->d=new_d;
    new_node->next=(*headref);
    (*headref)=new_node;
    }
    
    float avgofnodes(struct n*head)
    {
        if(!head){return -1;}
        int c=0;
        int s=0;
        float avg =0.0;
        struct n*now=head;
        while(now!=NULL)
        {
            c++;
            s+=now->d;
            now=now->next;
            }
        avg=(double)s/c;
        return avg;
        }

int main()
{
struct n*head=NULL;
push(&head , 7);
push(&head, 6);
push(&head, 8);
push(&head, 4);
push(&head, 1);
	cout<<"Average of nodes = "<<avgofnodes(head);
return 0;	
}

Example 7: c++ code to python code converter online

#include <iostream>
using namespace std;

int main()
{
    char gender;
    double bodyweight, wrist, waist, hip, forearm, B, bodyfat, bfPercentage, A1, A2, A3, A4, A5;

    bodyfat = bodyweight - B;
    bfPercentage = (bodyfat * 100) / bodyweight;

    cout << "Input gender (m/f): ";
    cin >> gender;

    switch (gender)
    {
    case 'F':
    case 'f':
        cout << "Enter body weight: ";
        cin >> bodyweight;
        cout << "Enter wrist measurement (at fullest point): ";
        cin >> wrist;
        cout << "Enter waist measurement (at navel): ";
        cin >> waist;
        cout << "Enter hip measurement (at fullest point): ";
        cin >> hip;
        cout << "Enter forearm measurement (at fullest point): ";
        cin >> forearm;

        A1 = (bodyweight * 0.723) + 8.987;
        A2 = (wrist) / 3.140;
        A3 = (waist) * 0.157;
        A4 = (hip) * 0.249;
        A5 = (forearm) * 0.434;

        B = A1 + A2 - A3 - A4 + A5;

        cout << "Your body fat is: " << bodyfat << endl
             << "Body fat percentage: " << bfPercentage << "%";
             break;

    case 'M':
    case 'm':
        cout << "Enter body weight: ";
        cin >> bodyweight;
        cout << "Enter wrist measurement (at fullest point): ";
        cin >> wrist;

        A1 = (bodyweight * 1.082) + 94.42;
        A2 = wrist * 4.14;

        B = A1 - A2;

        cout << "Your body fat is: " << bodyfat << endl
             << "Body fat percentage: " << bfPercentage << "%";
             break;

    default:
        cout << "Invalid gender.";
    }

    return 0;
}

Example 8: c++ code to python code converter online

#include <iostream>
using namespace std;

int main()
{
    char gender;
    double bodyweight, wrist, waist, hip, forearm, B, bodyfat, bfPercentage, A1, A2, A3, A4, A5;

    bodyfat = bodyweight - B;
    bfPercentage = (bodyfat * 100) / bodyweight;

    cout << "Input gender (m/f): ";
    cin >> gender;

    switch (gender)
    {
    case 'F':
    case 'f':
        cout << "Enter body weight: ";
        cin >> bodyweight;
        cout << "Enter wrist measurement (at fullest point): ";
        cin >> wrist;
        cout << "Enter waist measurement (at navel): ";
        cin >> waist;
        cout << "Enter hip measurement (at fullest point): ";
        cin >> hip;
        cout << "Enter forearm measurement (at fullest point): ";
        cin >> forearm;

        A1 = (bodyweight * 0.723) + 8.987;
        A2 = (wrist) / 3.140;
        A3 = (waist) * 0.157;
        A4 = (hip) * 0.249;
        A5 = (forearm) * 0.434;

        B = A1 + A2 - A3 - A4 + A5;

        cout << "Your body fat is: " << bodyfat << endl
             << "Body fat percentage: " << bfPercentage << "%";
             break;

    case 'M':
    case 'm':
        cout << "Enter body weight: ";
        cin >> bodyweight;
        cout << "Enter wrist measurement (at fullest point): ";
        cin >> wrist;

        A1 = (bodyweight * 1.082) + 94.42;
        A2 = wrist * 4.14;

        B = A1 - A2;

        cout << "Your body fat is: " << bodyfat << endl
             << "Body fat percentage: " << bfPercentage << "%";
             break;

    default:
        cout << "Invalid gender.";
    }

    return 0;
}

Example 9: c++ code to python code converter online

#include <iostream>
using namespace std;

int main()
{
    char gender;
    double bodyweight, wrist, waist, hip, forearm, B, bodyfat, bfPercentage, A1, A2, A3, A4, A5;

    bodyfat = bodyweight - B;
    bfPercentage = (bodyfat * 100) / bodyweight;

    cout << "Input gender (m/f): ";
    cin >> gender;

    switch (gender)
    {
    case 'F':
    case 'f':
        cout << "Enter body weight: ";
        cin >> bodyweight;
        cout << "Enter wrist measurement (at fullest point): ";
        cin >> wrist;
        cout << "Enter waist measurement (at navel): ";
        cin >> waist;
        cout << "Enter hip measurement (at fullest point): ";
        cin >> hip;
        cout << "Enter forearm measurement (at fullest point): ";
        cin >> forearm;

        A1 = (bodyweight * 0.723) + 8.987;
        A2 = (wrist) / 3.140;
        A3 = (waist) * 0.157;
        A4 = (hip) * 0.249;
        A5 = (forearm) * 0.434;

        B = A1 + A2 - A3 - A4 + A5;

        cout << "Your body fat is: " << bodyfat << endl
             << "Body fat percentage: " << bfPercentage << "%";
             break;

    case 'M':
    case 'm':
        cout << "Enter body weight: ";
        cin >> bodyweight;
        cout << "Enter wrist measurement (at fullest point): ";
        cin >> wrist;

        A1 = (bodyweight * 1.082) + 94.42;
        A2 = wrist * 4.14;

        B = A1 - A2;

        cout << "Your body fat is: " << bodyfat << endl
             << "Body fat percentage: " << bfPercentage << "%";
             break;

    default:
        cout << "Invalid gender.";
    }

    return 0;
}