C programming, windows and mac

0 Ash Marz · June 16, 2015
I already have a pre built c program file that I built on windows, but now I want to run it on mac but its not working so how do I do it?

Here is the code: 

int main()
{
int ab;
printf("Enter value for ab: \n \n");
scanf("%d", &ab)"\n";
int cd;
printf("Enter value for cd: \n \n");
scanf("%d", &cd);
int ef = ab +cd;
printf("The value for the total is %d \n \n \n", ef);


int sales=0;
sales=sales + 1;
printf("The sales is %d \n", sales);

sales=sales + 1;
printf("The sales is %d \n", sales);

sales=sales + 1;
printf("The sales is %d \n \n \n", sales);

float a;
float b;
float c;
float avg;



printf("Enter value for a: \n");
scanf("%f", &a);
printf("Enter value for b: \n");
scanf("%f", &b);
printf("Enter value for c: \n");
scanf("%f", &c);
avg = (a+b+c)/3;
printf("The average value is %.2f",avg);

    return 0;
}

Post a Reply

Replies

Oldest  Newest  Rating
0 Reynaldo Gunawan · June 16, 2015
Hi, i'm a mac user and i don't see a reason that you would have a problem running that code on mac. I'm not sure if the setting under "Properties" can be the problem, but it's worth a look if no solution is found.
Also, another thing that worth noting is that, sometimes for the function scanf (especially when dealing with character) it is wise to put a space after the quotation mark, hence scanf(" %d").

Sorry if i'm not much of a help...
  • 1

C

107,049 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator