Welcome To Program a Simple Program in C

First we need to Understand the basics of C programming:

We will start with the body of a program:

1. #include <stdio.h> this is a library in the C compiler which is the software where you run the programs.

2. int main() this is the main function of the program, the body of the program will be inside this function.


3. { int x, y, z; this is the declaration of variables of type integer

printf('''); is a function in the compiler which outputs what's in between the " "

to the monitor

4. printf("Enter two numbers to multiply(enter a space between numbers): ");

scanf(""); is another function except this one inputs what's in between the " " and

stores it into the variable for this example x and y

5. scanf("%d%d", &x, &y);

6. z = x * y; the = sign is an assignment to the left, so it assigns the product of x and y to the variable z

7. printf("The product is : %d", z);

8. return 0; this code is what tells the compiler that you are terminating the program it returns 0 to the operating system

9. } this is the closing bracket just like in a math funtion


Enter two numbers to multiply(enter a space between numbers): 5 9

The product is : 45

Here is a website about C programming

back to previous page


Send e-mail to wilber_rivas@hotmail.com

These pages were made through TeacherTECH, the teacher professional development component of GirlTECH, which is sponsored by the Center for Excellence and Equity in Education (CEEE) with support from the National Science Foundation through EOT-PACI, RGK Foundation, the Verizon Foundation, Rice University, and HiPerSoft.

Copyright © June 2002 by Wilber R. Rivas.