Why wont my code in C won't compile?

Home » Programming & Design » Why wont my code in C won't compile?
Programming & Design No Comments

Why wont my code won't execute??

Hi, C programming dumbass here.

It is a simple program where you must type a number and a car's info will show up. As you can see, press 1 for Chevrolet Malibu, on the program. I didn't know why it wont execute.

#include <stdio.h>
int main()
{

Why wont my code won't execute??

Hi, C programming dumbass here.

It is a simple program where you must type a number and a car's info will show up. As you can see, press 1 for Chevrolet Malibu, on the program. I didn't know why it wont execute.

#include <stdio.h>
int main()
{
printf("\t\tFive New Cars In 2016 And Their Infos\n\n");

int num;

Best Answer:

Japhet: There are several errors. The code below corrects some of them. (Note that Yahoo Answers is terrible at presenting code examples, as it removes all "extra" whitespace. I've inserted "@" to make the expected indenting more meaningful.)

#include <stdio.h>
int main()
{
@@printf("\t\tFive New Cars In 2016 And Their Infos\n\n");

@@int number;
@@printf("Enter you desired number to choose a car\n\n");
@@printf("Press 1 for Chevrolet Malibu\n");
@@printf("Press 2 for Honda Accord\n");
@@printf("Press 3 for Mazda 6\n");
@@printf("Press 4 for Chrysler 200\n");
@@printf("Press 5 for Ford Fusion\n");

@@printf("Enter number:");
@@scanf("%d", &number);

@@if (number = 1 )
@@@@{
@@@@@@printf("Chevrolet Malibu %d", number);
@@@@}
}

Here are your errors.
1. You used the names "num" and "number" for the same variable. Choose one of them and stick with it.
2. Your printf statement failed to include the %d required to show the value of number.
3. You omitted the closing } for the program.

There are several other errors, but they do not prevent the code from compiling. I'm not going to tell you what they are, but you should pay attention to grammar, completeness, and output format. Also, I imagine that your assignment expected you to use a switch statement instead of a series of if statements.

Other answer:

Japhet:
Hi so how has this software issue found it's way into the car and motoring section. the main reason software does not compile is because it has mistakes in it. a space too many or a dot in the wrong place the issues are countless.
Pankaj Adiley:
Have you ever written a code??
if(num==1) is right
if(num=1) is wrong.

You're using assignment operator = instead of equality == e.i. double equals

Japhet:
Wow people here are being a complete ***, this is my honest attempt. Be thankfull I didnt give up on coding..
Sarah:
Gffv

LEAVE A COMMENT