hi, please help me how can i convert this C++ code to C source code ... please help .....

this is the URL http://cppforschool.com/project/super-market-billing.html i dont understand this though please help ... :(((((((

May I ask why you need to convert that code to C? Seems suspicious.

Looks like all you have to do is call printf() instead of cout, replace cin with scanf(), change class to struct, and change the methods that are in the class to global functions. You may have to add a parameter or two to the functions in order to make that work.

@deceptikon- i'm going to use it on my project please help? :((

@Ancient Dragon- thanks for the help but can you help me how to add parameters???

very simple to add parameters, assuming you named the structure product

void create_product(struct product*p)
{
printf("\nPlease Enter The Product No. of The Product \n");
scanf("%d",&p->pno);
printf(\n\nPlease Enter The Name of The Product \n");
fgets(p->name, sizeof(p->name), stdin);
printf("\nPlease Enter The Price of The Product \n");
scanf("%f",&p->price);
printf("\nPlease Enter The Discount (%) \n");
scanf("%f",&p->dis);
}
#include<bits/stdc++.h>
using namespace std;
long long int color[51]={0},cost[51]={0};

int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,c;
scanf("%d%d",&n,&c);
memset(color,0,sizeof(color));
memset(cost,0,sizeof(cost));
long long int dp1[51][51]={0},dp2[51][51]={0};
/*for(int i=0;i<41;i++)
for(int j=0;j<41;j++)
{
dp1[i][j]=0;
dp2[i][j]=0;
}
*/
for(int i=0;i<n;i++)
{
int a,b;
scanf("%d%d",&a,&b);
color[a]++;
cost[a] += b;
}
dp1[0][0]=1.0;
for(int i=1;i<41;i++)
{
dp1[i][0]=1.0;
for(int j=1;j<i+1;j++)
{
if(color[i]>0)
dp1[i][j]= dp1[i-1][j] + dp1[i-1][j-1]*((1LL<<color[i])-1);
else
dp1[i][j]=dp1[i-1][j];
}
}
for(int i=1;i<41;i++)
{
for(int j=1;j<i+1;j++)
{
if(color[i]>0)
dp2[i][j]= dp2[i-1][j] + dp2[i-1][j-1]*((1LL<<color[i])-1) + cost[i]*(1LL<<(color[i]-1))*dp1[i-1][j-1];
else
dp2[i][j]=dp2[i-1][j];
}
}
double num=0, den=0;
for(int i= c;i<=n;i++)
{
//cout<<dp1[40][i]<<" "<<dp2[40][i]<<endl;
num += dp2[40][i];
den += dp1[40][i];
}
printf("%.9lf\n",(double)(num/den));
}   
} 

HOW TO CONVERT THIS PROGRAM INTO C LANGUAGE

#include<iostream.h>
#include<string.h>
#include<conio.h>
int nt,t,top=0;
char s[50],NT[10],T[10],st[50],l[10][10],tr[50][50];
int searchnt(char a)
{
int count=-1,i;
for(i=0;i<nt;i++)#include<iostream.h>
#include<string.h>
#include<conio.h>
int nt,t,top=0;
char s[50],NT[10],T[10],st[50],l[10][10],tr[50][50];
int searchnt(char a)
{
int count=-1,i;
for(i=0;i<nt;i++)
{
if(NT[i]==a)
return i;
}
return count;
}
int searchter(char a)
{
int count=-1,i;
for(i=0;i<t;i++)
{
if(T[i]==a)
return i;
}
return count;
}
void push(char a)
{
s[top]=a;
top++;
}
char pop()
{
top--;
return s[top];
}
void installl(int a,int b) 
{
if(l[a][b]=='f')
{
l[a][b]='t';
push(T[b]);
push(NT[a]);
}}
void installt(int a,int b)
{
if(tr[a][b]=='f')
{
tr[a][b]='t';
push(T[b]);
push(NT[a]);
}}
void main()
{
int i,s,k,j,n;
char pr[30][30],b,c;
clrscr();
cout<<"Enter the no of productions:";
cin>>n;
cout<<"Enter the productions one by one\n";
for(i=0;i<n;i++)
cin>>pr[i];
nt=0;
t=0;
for(i=0;i<n;i++)
{
if((searchnt(pr[i][0]))==-1)
NT[nt++]=pr[i][0];
}
for(i=0;i<n;i++){
for(j=3;j<strlen(pr[i]);j++){
if(searchnt(pr[i][j])==-1)
{
if(searchter(pr[i][j])==-1)
T[t++]=pr[i][j];
}}}
for(i=0;i<nt;i++){
for(j=0;j<t;j++)
l[i][j]='f';
}
for(i=0;i<nt;i++){
for(j=0;j<t;j++)
tr[i][j]='f';
}
for(i=0;i<nt;i++)
{
for(j=0;j<n;j++)
{
if(NT[(searchnt(pr[j][0]))]==NT[i])
{
if(searchter(pr[j][3])!=-1)
installl(searchnt(pr[j][0]),searchter(pr[j][3]));
else
{
for(k=3;k<strlen(pr[j]);k++){
if(searchnt(pr[j][k])==-1)
{
installl(searchnt(pr[j][0]),searchter(pr[j][k]));
break;
}}}}}}
while(top!=0)
{
b=pop();
c=pop();
for(s=0;s<n;s++){
if(pr[s][3]==b)
installl(searchnt(pr[s][0]),searchter(c));
}}
for(i=0;i<nt;i++)
{
cout<<"Leading["<<NT[i]<<"]"<<"\t{";
for(j=0;j<t;j++){
if(l[i][j]=='t')
cout<<T[j]<<",";
}
cout<<"}\n";
}
top=0;
for(i=0;i<nt;i++){
for(j=0;j<n;j++){
if(NT[searchnt(pr[j][0])]==NT[i])
{
if(searchter(pr[j][strlen(pr[j])-1])!=-1)
installt(searchnt(pr[j][0]),searchter(pr[j][strlen(pr[j])-1]));
else
{
for(k=(strlen(pr[j])-1);k>=3;k--)
{
if(searchnt(pr[j][k])==-1)
{
installt(searchnt(pr[j][0]),searchter(pr[j][k]));
break;
}}}}}}
while(top!=0)
{
b=pop();
c=pop();
for(s=0;s<n;s++)
{
if(pr[s][3]==b)
installt(searchnt(pr[s][0]),searchter(c));
}}
for(i=0;i<nt;i++)
{
cout<<"Trailing["<<NT[i]<<"]"<<"\t{";
for(j=0;j<t;j++)
{
if(tr[i][j]=='t')
cout<<T[j]<<",";
}
cout<<"}\n";
}
getch();
}

{
if(NT[i]==a)
return i;
}
return count;
}
int searchter(char a)
{
int count=-1,i;
for(i=0;i<t;i++)
{
if(T[i]==a)
return i;
}
return count;
}
void push(char a)
{
s[top]=a;
top++;
}
char pop()
{
top--;
return s[top];
}
void installl(int a,int b) 
{
if(l[a][b]=='f')
{
l[a][b]='t';
push(T[b]);
push(NT[a]);
}}
void installt(int a,int b)
{
if(tr[a][b]=='f')
{
tr[a][b]='t';
push(T[b]);
push(NT[a]);
}}
void main()
{
int i,s,k,j,n;
char pr[30][30],b,c;
clrscr();
cout<<"Enter the no of productions:";
cin>>n;
cout<<"Enter the productions one by one\n";
for(i=0;i<n;i++)
cin>>pr[i];
nt=0;
t=0;
for(i=0;i<n;i++)
{
if((searchnt(pr[i][0]))==-1)
NT[nt++]=pr[i][0];
}
for(i=0;i<n;i++){
for(j=3;j<strlen(pr[i]);j++){
if(searchnt(pr[i][j])==-1)
{
if(searchter(pr[i][j])==-1)
T[t++]=pr[i][j];
}}}
for(i=0;i<nt;i++){
for(j=0;j<t;j++)
l[i][j]='f';
}
for(i=0;i<nt;i++){
for(j=0;j<t;j++)
tr[i][j]='f';
}
for(i=0;i<nt;i++)
{
for(j=0;j<n;j++)
{
if(NT[(searchnt(pr[j][0]))]==NT[i])
{
if(searchter(pr[j][3])!=-1)
installl(searchnt(pr[j][0]),searchter(pr[j][3]));
else
{
for(k=3;k<strlen(pr[j]);k++){
if(searchnt(pr[j][k])==-1)
{
installl(searchnt(pr[j][0]),searchter(pr[j][k]));
break;
}}}}}}
while(top!=0)
{
b=pop();
c=pop();
for(s=0;s<n;s++){
if(pr[s][3]==b)
installl(searchnt(pr[s][0]),searchter(c));
}}
for(i=0;i<nt;i++)
{
cout<<"Leading["<<NT[i]<<"]"<<"\t{";
for(j=0;j<t;j++){
if(l[i][j]=='t')
cout<<T[j]<<",";
}
cout<<"}\n";
}
top=0;
for(i=0;i<nt;i++){
for(j=0;j<n;j++){
if(NT[searchnt(pr[j][0])]==NT[i])
{
if(searchter(pr[j][strlen(pr[j])-1])!=-1)
installt(searchnt(pr[j][0]),searchter(pr[j][strlen(pr[j])-1]));
else
{
for(k=(strlen(pr[j])-1);k>=3;k--)
{
if(searchnt(pr[j][k])==-1)
{
installt(searchnt(pr[j][0]),searchter(pr[j][k]));
break;
}}}}}}
while(top!=0)
{
b=pop();
c=pop();
for(s=0;s<n;s++)
{
if(pr[s][3]==b)
installt(searchnt(pr[s][0]),searchter(c));
}}
for(i=0;i<nt;i++)
{
cout<<"Trailing["<<NT[i]<<"]"<<"\t{";
for(j=0;j<t;j++)
{
if(tr[i][j]=='t')
cout<<T[j]<<",";
}
cout<<"}\n";
}
getch();
}

Can you guys help me convert this C++ language to C language

float y, k;
cout << "Enter the Radius of the desired circle size" ;
cin >> y;
float m = 2;

for (int i = -y; i <= y; i++)
{
    for (int j = -y; j <= y; j++)
    {
        k = ((i * m) / y) * ((i * m) / y) + (j / y) * (j / y);

        if (k > 0.95 && k < 1.08)
        {
            cout << "*";
        }
        else
        {
            cout << " ";
        }
    }
    cout << "\n";
}
return 0;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.