Hello everyone ,
Now I just want to share you about my knowledge. I am learning C Programming now. So I think it is better to me to share with everyone although I just know the basic of C right now. But if I forget about the basic one day. I can read this article again. That’s good, isn’t it? :D
okay lets we start ,
To make a program, we are better to make a algorithms and flowchart before we start to code the program.
I start with the algorithms first :
The Algorithms :
- there are 3 parts that create a beam : Long(L), Width(W) , Height(H).
- input a number for the 3 parts.
- operate them with this formula :
surface area = 2 x (L*W+L*H+W*H)
volume = L * W * H
we can use integer or float as the type of data. But I use integer for this tutorial.
Now I just want to share you about my knowledge. I am learning C Programming now. So I think it is better to me to share with everyone although I just know the basic of C right now. But if I forget about the basic one day. I can read this article again. That’s good, isn’t it? :D
okay lets we start ,
To make a program, we are better to make a algorithms and flowchart before we start to code the program.
I start with the algorithms first :
The Algorithms :
- there are 3 parts that create a beam : Long(L), Width(W) , Height(H).
- input a number for the 3 parts.
- operate them with this formula :
surface area = 2 x (L*W+L*H+W*H)
volume = L * W * H
we can use integer or float as the type of data. But I use integer for this tutorial.
Flowchart :
Now we have the algorithms and the flowchart.
Lets we start code the program. Okay here I will give you the script :
#include <stdio.h>
main()
#include <stdio.h>
main()
{
// MUHAMMAD IDRIS
int l,w,h;
printf("Input length??");
scanf("%i",&l);
printf("Input width??");
scanf("%i",&w);
printf("Input height??");
scanf("%i",&h);
printf(" Diketahui : l = %i \t w = %i \t h = %i \n",w,l,h);
printf("Surface area of rectangular prism is %d m2\n ", 2*(l*w+l*h+w*h); /*
printf(" Volume balok adalah %d m3\n" , l*w*h);
return 0;
// Save with name.c
}
}
I code the program in my ubuntu. So this is how to compile and make an executable file :
1. Open terminal.
2. Enter to the directory where you saved the c script.
3. Compile it : gcc –c name.c
4. Make it be executable : gcc name.c –o name
5. Execute it : ./name
and here is the screenshot to proof you that this program is succesfull. This screenshot is in Indonesian. But I have changed the code in English . It doesn’t make any difference, just the language :D .
1. Open terminal.
2. Enter to the directory where you saved the c script.
3. Compile it : gcc –c name.c
4. Make it be executable : gcc name.c –o name
5. Execute it : ./name
and here is the screenshot to proof you that this program is succesfull. This screenshot is in Indonesian. But I have changed the code in English . It doesn’t make any difference, just the language :D .
Thanks for read my article and Keep spirit.
No comments:
Post a Comment