View Full Version : programing in C language?!
Hi all,
I am learning C language in S-Function Simulink
does any one prgram in C?
I need help please
Thanks
Lots of people program in C, including quite a few here at Physics Forum. What difficulties are you having?
well, i am quite novice and i have some error i need to debug in C code
can you help me please?
thanks
black_em2
Dec1-10, 11:51 AM
Well you are going to need to post your code, your errors, and the goal of the program or no one will be able to help you.
here is my code and thanks for your help in advance!!!
double theta, A1, A2, phi, C, A0, L ;
theta = 1;
A0 = 0.7;
L = 0.160;
C = sqrt(A0*A0 + L*L);
phi = atan(A0/L);
//************************************************** ************************
if (C*C + L*L - 2*L*C*cos(phi - theta)>0.0);
{
A1 = sqrt(C*C + L*L - 2*L*C*cos(phi - theta));
}
else if (C*C + L*L - 2*L*C*cos(phi - theta)<0.0);
{
printf("error -- sqrt_negative\n");
}
if (C*C + L*L - 2*L*C*cos(phi + theta)>0.0);
{
A2 = sqrt(C*C + L*L - 2*L*C*cos(phi + theta));
}
else if (C*C + L*L - 2*L*C*cos(phi + theta)<0.0);
{
printf("error -- sqrt_negative\n");
}
I get these errors:
syntax error; found `if' expecting `;'
unrecognized statement
here is my code and thanks for your help in advance!!!
double theta, A1, A2, phi, C, A0, L ;
theta = 1;
A0 = 0.7;
L = 0.160;
C = sqrt(A0*A0 + L*L);
phi = atan(A0/L);
//************************************************** ************************
if (C*C + L*L - 2*L*C*cos(phi - theta)>0.0);<---- Remove semicolon
{
A1 = sqrt(C*C + L*L - 2*L*C*cos(phi - theta));
}
else if (C*C + L*L - 2*L*C*cos(phi - theta)<0.0);<---- Remove semicolon
{
printf("error -- sqrt_negative\n");
}
if (C*C + L*L - 2*L*C*cos(phi + theta)>0.0);<--- Remove semicolon
{
A2 = sqrt(C*C + L*L - 2*L*C*cos(phi + theta));
}
else if (C*C + L*L - 2*L*C*cos(phi + theta)<0.0);<--- Remove semicolon
{
printf("error -- sqrt_negative\n");
}
I get these errors:
syntax error; found `if' expecting `;'
unrecognized statement
You have some extra semicolons that need to be removed.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.