Thursday, March 8, 2012

IDENTIFY COMPONENTS PROGRAM C++ Programing Language

This time we will learn to identify and recognize the structure / component in a program, as well as identify errors that occur in programs that we make.

in the previous post we have studied the structure or component in a program, namely:
1. Identifier (variables, constants, data types and functions).
2. Data types (int, float, char, etc.).
3. Variable Declaration.
4. Assignment / Grading
5. Constants
6. Comment



Now we will create a more simple program in which there are several components, not all the components we enter, we will only use the header, variables, data types, assignment, and comments. We will also determine which part is called the header, variables, data types, assignment, and comments.

Program that we will create is the program to calculate the area of triangles, which we will give titles Count Area of a Triangle.

Script Program :

IDENTIFY COMPONENTS PROGRAM C++ Programing Language

In the script above we can see what is contained therein, the explanation is written on his comments. Now we will execute the program and see the output generated by sciprt program we have created.

Output Program (compiler : borland C++) :

 

that is the output that will be generated by the program. Next we will identify a program that there are some errors in it. we will use the same program as above. but we will correct what is wrong section, and not in accordance with the above script program.

Script Program :

IDENTIFY COMPONENTS PROGRAM C++ Programing Language

errors that occur after the compilation:

IDENTIFY COMPONENTS PROGRAM C++ Programing Language


Identification of Errors that occur in program :
1. Header :  
#include (conio.h) should be #include <conio.h>

2. Deklarasi variabel :
int base, height, area. should be int base, height, area;

3. Masukan / Input :
scanf("%d",base); and scanf("%d",height) should be scanf("%d",&base); and scanf("%d",&height);

4. Keluaran /Output :
printf("\nLuas Segitiga = %d", &area); should be printf("\nLuas Segitiga = %d", area);

So that I can convey in this post, may can be helpful in learning the programming language C / C + +.

1 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete