| The First C Program To start with the first program lets write what we actually want to instruct the Computer Processor to do: - I want the Computer Processor to display character that I type - I want it to be displayed on the Computer Monitor Screen - I will type the character on my keyboard and I want the Computer Processor to read what I typed. In order to do all of this certainly we need a complete Computer Set System and obviously by reading this tutorial you already got everything. Lets write the program on the C Compiler. Open the C Compiler and open new file to write C program. Write the program and save it as First.c. #include <stdio.h> int main() { printf("Processor please display this character!\n"); return 0; } Compile the C program as shown below: Run the program and the output is shown below: When executed, this program instructs the computer to print out the line - Processor please display this character! -- then the program quits. To make the program display the output until we type any character just add C code getchar() inside the program. #include <stdio.h> int main() { printf("Processor please display this character!\n"); getchar(); //output will wait until user type any //cahr on the keyboard return 0; } Next Page >> |