Horje
convert c++ code to c online Code Example
convert c++ code to c online
#include<stdio.h>
convert c++ code to c online
 #include <iostream>
#include<stdlib>

using namespace std;
 

typedef struct node
{

  int val;

  struct node* next;
}node;
 
node* head=NULL;
 

int count(node* head) // code to count the no. of nodes
{

  node* p=head;

  int k=1;

  while(p!=NULL)

  {

    p=p->next;

    k++;

  }

  return k;
}
 

node ll_reverse(node head)  // to reverse the linked list
{

  node* p=head;

  long int i=count(head),j=1;

  long int arr[i];

  while(i && p!=NULL)

  {

    arr[j++]=p->val;

    p=p->next;

    i--;

  }

  j--; 

  while(j) // loop will break as soon as j=0

  {

    cout<<arr[j--]<<" ";

  }

   

  return head;
}
 

node* insert_end(node* head,int data)  //code to insert at end of ll
{

  node* q=head,p=(node)malloc(sizeof(node));

  p->val=data;

  while(q->next!=NULL)

  {

    q=q->next;

  }

  q->next=p;

  p->next=NULL;

  return head;
}
 

node create_ll(node head,int data)  //create ll
{

  node* p=(node*)malloc(sizeof(node));

  p->val=data;

  if(head==NULL)

  {

    head=p;

    p->next=NULL;

    return head;

  }

  else

  {

    head=insert_end(head,data);

    return head;

  }
}
 
//Driver code
 

int main() 
{

  int i=5,j=1;  

  while(i--)

  {

    head=create_ll(head,j++);

  }

  head=ll_reverse(head);  

    return 0;
}
convert c++ code to c online
#include<iostream>
using namespace std;
const int n=8;
main(){
int T[n]={7,11,4,8,2,5,14,3};
int i, max,pmax,min,pmin;
for(i=0;i < n;i++)
if(!i){ // se i=0 inizializzo le var.
     max=T[i];pmax=1;
     min=T[i];pmin=1;
     }else{
          if(T[i] > max){
               max=T[i];
               pmax=i+1;
          }//fine if(T[i] > max)
          if(T[i] < min){
               min=T[i];
               pmin=i+1;
          }//fine if(T[i] < min)
}//fine if(!i)-else
cout << max << " " << pmax << endl;
cout << min << " " << pmin << endl;
}//fine main
convert c++ code to c online
#include <bits/stdc++.h>
using namespace std;
main() {
	int t,n;
	int j=1;
	cin>>t;
	while(t--){
		cin>>n;
		cout<<"#"<<j<<" ";
		for(int i=0;i<n;i++){
			cout<<"SVMC"<<" ";
		}
		j++;
		cout<<endl;
	}
}
convert c++ code to c online
#include<iostream>
int main()
{
int x,y,z;
float i,a,d,f;
std::cin>>x>>y>>z;
std::cin>>i>>a>>d>>f;
i=(x*y*z)/100;
a=x+i;
d=(i*2)/100;
f=a-d;
std::cout<<i<<"\n"<<a<<"\n"<<d<<"\n"<<f;
}
convert c++ code to c online
public class Mythread {

    public static void main(String[] args) {
        Runnable r = new Runnable1();
        Thread t = new Thread(r);
        t.start();
        Runnable r2 = new Runnable2();
        Thread t2 = new Thread(r2);
        t2.start();
    }
}

class Runnable2 implements Runnable{
    public void run(){
        for(int i=0;i<11;i++){
            if(i%2 == 1)
                System.out.println(i);
        }
    }
}

class Runnable1 implements Runnable{
    public void run(){
        for(int i=0;i<11;i++){
            if(i%2 == 0)
                System.out.println(i);
        }
    }
convert c++ code to c online
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,c=0;
    cout<<n;
    int a[n];
    int b[n];
    for(inti=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }

sort(a,a+n);
for(int i=0;i<n;i++)
{
    if(a[i]==b[i])
    c++;    
}
count<<c;
return 0;
}

    return 0;
}
convert c++ code to c online
#include <iostream>
using namespace std;

int main()

{

int sz;

cout<<"Enter the size of array::";

cin>>sz;

int randArray[sz];

for(int i=0;i<sz;i++)

randArray[i]=rand()%1000; //Generate number between 0 to 999

cout<<"\nElements of the array::"<<endl;

for(int i=0;i<sz;i++)

cout<<"Elements no "<<i+1<<"::"<<randArray[i]<<endl;

return 0;

}
convert c++ code to c online
#include<iostream>
#include<cstdio>
using namespace std;
long long ans=0;
void mergei(int a[],int i,int j){
    int ni=((i+j)/2)+1,nj=j+1;int s=i;
    int * arr = new int [j-i+1]; j=ni;int k=0;
    while(i<ni && j<nj){
        if(a[i]<=a[j]){
            arr[k]=a[i];
            i++; } else {
            arr[k]=a[j];
            ans+=(ni-i);
            j++; } k++; }
    for(;i<ni;i++,k++)
        arr[k]=a[i];
    for(;j<nj;j++,k++)
        arr[k]=a[j];
    for(k=0;s<nj;s++,k++)
        a[s]=arr[k];
    delete [] arr; }
void m_sort(int a[],int i,int j){
    if(i<j) {
        m_sort(a,i,(i+j)/2);
        m_sort(a,((i+j)/2)+1,j);
        mergei(a,i,j);} }
int main() {
    int t;
    scanf("%d",&t);
    while(t--) {
        int n;ans=0; scanf("%d",&n);int * a = new int[n];
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]);
        m_sort(a,0,n-1);
        cout<<ans<<endl; } return 0;
}
convert c++ code to c online
#include<bits/stdc++.h>
using namespace std;

void printWords(string str)
{
	// word variable to store word
	string word;

	// making a string stream
	stringstream iss(str);

	// Read and print each word.
	while (iss >> word){
		reverse(word.begin(),word.end());
		cout<<word<<" ";
	}
}

// Driver code
int main()
{
	string s = "GeeksforGeeks is good to learn";
	printWords(s);
	return 0;
}
// This code is contributed by Nikhil Rawat




Cpp

Related
javascript if else exercises Code Example javascript if else exercises Code Example
Polycarp found a rectangular table consisting of n rows and m columns. He noticed that each cell of the table has its number, obtained by the following algorithm "by columns": codeforces solu Polycarp found a rectangular table consisting of n rows and m columns. He noticed that each cell of the table has its number, obtained by the following algorithm "by columns": codeforces solu
sort(arr arr+n) in c++ Code Example sort(arr arr+n) in c++ Code Example
c++ main function parameters Code Example c++ main function parameters Code Example
c to c++ converter online Code Example c to c++ converter online Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10