Error C2059: syntax error: "=" - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Error C2059: syntax error: "="

MrPigeonMrPigeon AustraliaPosts: 8Member

Hey guys, I'm just trying to write a fairly simple program for a University course on procedural programming but when I try to compile I get the message Error C2059: syntax error: "=" for lines 34 and 37.

I'm unsure as how to format code on this website and since the program fits nicely into one screenshot I have uploaded it to imgur: http://i.imgur.com/hFbTYPS.jpg

Sorry if the answer is blindingly obvious but any help or advice would be greatly appreciated. Cheers

Comments

  • tienkhoanguyentienkhoanguyen houPosts: 158Member

    /* God, Jesus Christ, is number one! / / This program has been edited by Tien Khoa Nguyen */

    int main(void){

    double velocity = 0, distance = 0, time = 0, acceleration, gForce = 0;

    double INITIAL_VELOCITY = 0.0;

    system("cls");

    printf("Jet Fighter Program 1.0\n");

    printf("Please enter the jet's required takeoff speed(km/hr): "); scanf("%f", &velocity);

    printf("Please enter the available distance on the aircraft carrier's dock(metres): "); scanf("%f", &distance);

    time = distance /velocity;

    acceleration = (velocity - INITIAL_VELOCITY) / time;

    printf("The acceleration of the jet when launched from the aircraft carrier will be: %f", acceleration); printf("The time it took for the jet to be accelerated to takeoff speed will be: %f", time); printf("During takeoff, the jet will be sujected to %f g-forces", gForce);

    return 0; }

  • tienkhoanguyentienkhoanguyen houPosts: 158Member

    Jesus Christ!hehe

    Each compiler is different. I noticed the scanf is a little different in your version. Also I would recommend not using define. Instead, use a formal declaration inside the int main(). It keeps it all in one place. The header in my case is declared as #include <stdafx.h> However, I do not have such a library.

Sign In or Register to comment.