convert c++ code to c online
#include
convert c++ code to c online
#include
#include
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<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
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
using namespace std;
main() {
int t,n;
int j=1;
cin>>t;
while(t--){
cin>>n;
cout<<"#"<
convert c++ code to c online
#include
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<
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
using namespace std;
int main()
{
int n,c=0;
cout<>a[i];
b[i]=a[i];
}
sort(a,a+n);
for(int i=0;i
convert c++ code to c online
#include
using namespace std;
int main()
{
int sz;
cout<<"Enter the size of array::";
cin>>sz;
int randArray[sz];
for(int i=0;i
convert c++ code to c online
#include
#include
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
convert c++ code to c online
#include
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<
|