Newbie C Questions
Newbie C Questions
- Subject: Newbie C Questions
- From: Tom McKenna <email@hidden>
- Date: Tue, 29 Jan 2002 22:05:22 -0500
Originally I planned on teaching myself Cocoa from the "Learning Cocoa"
book. Since my programming experience is limited to Commodore Basic, I
found the book to be somewhat over my head. (OK, way over my head...)
I then decided to learn C, since Objective-C is ANSI C plus all of the
object-oriented material. Since I was able to get a beginner's book on
C, it has been much easier to learn.
Here are my questions (finally):
* When I am using Project Builder and I want to create a simple C
application, what kind of project should I be opening? (I have been
using the 'Standard Tool' option in PB...)
* Once I finish this book on C, I would like to learn Objective-C. Is
there a beginner's book that doesn't work under the assumption that you
know C++ or Java? If not, what should I do next?
* One of my tutorial apps compiles fine in PB, but it won't run in PB.
It does run perfectly in the Terminal. Am I doing something wrong?
Here's the code:
#include <stdio.h>
/* Filename: Avg.C */
/* Computes the average of three class grades */
main ()
{
float gr1, gr2, gr3;
float avg;
// Asks for each student's grade
printf("What grade did the first student get? ");
scanf(" %f", &gr1);
printf("What grade did the second student get? ");
scanf(" %f", &gr2);
printf("What grade did the third student get? ");
scanf(" %f", &gr3);
// Calculates the average of the three student's grades
avg = (gr1 + gr2 + gr3) / 3.0;
printf("\nThe student average is %.2f", avg);
return 0;
}
Thanks for any and all help, advice you can offer!
Sincerely,
Tom McKenna