I am trying to learn Xcode with C as a start to learning to program. So far I have not gotten Xcode to successfully build and run a program using C on Mac OS.
Any recommendations on basic troubleshooting for Xcode setup and orientation. Every program I try to run says "Build failed".
Post
Replies
Boosts
Views
Activity
No luck with my first post in getting a response despite 24 views. Will try again.
I am trying to build/run this main() function in C language. Keep getting build fail message.
#include <stdio.h>
#include <math.h>
int main()
{
float a,b;
printf("Enter value for A: ");
scanf("%f" ,&a);
printf("Enter value for B: ");
scanf("%f" ,&b);
printf("%f + %f = %f\n",a,b,a+b);
printf("%f - %f = %f\n",a,b,a-b);
printf("%f * %f = %f\n",a,b,a*b);
printf("%f / %f = %f\n",a,b,a/b);
printf("%f to the power of %f = %f\n",a,b,pow(a,b));
printf("The square root of %f is %f\n",a,sqrt(a));
printf("The square root of %f is %f\n",a,sqrt(b));
return(0);
}
ANY feedback appreciated on why Xcode does not work here. I am a beginning programmer.
Thanks.
I am self-learning basic C programming and have installed Xcode v. 14.2 on MacOS Monterey v. 12.7.5. I cannot get any programs I write under a new project I created to build and run on Xcode. Here is an example of what I am trying to build and run:
#include <stdio.h>
int main()
{
char test_string[] = "new string text";
printf("This process will %s\n",test_string);
return(0);
}
Any guidance or feedback would be appreciated.