What Will I Learn?
- You will learn basic C language
- You will learn to make simple programs
- You will learn how to combine multiple programs in one compile
Requirements
- Have a basic knowledge of C language
- DEV C ++ Compile and Run C/C++ program on Windows
- GCC Compile and Run C / C ++ program on Linux
Difficulty
- Basic
Tutorial Contents
- What is a C programming language ?
- What is the use and should learn ?
Programming Language C
C Programming Language is a computer programming language that can be used to create applications (general-purpose programming language), from operating systems (such as Windows or Linux), antivirus, image processing software, to compilers for programming languages, where C is widely used to create other programming languages which one of them is PHP.
Although it is a general-purpose programming language, a programming language that can create applications, C programming languages are best suited for designing applications that deal directly with Operating Systems and hardware.
- So my goal is how to make some simple program. And combine some simple programs that we have created later into one compile
Some examples of simple C programs
- C program distinguishes small and large numbers, and use if else condition
#include
int main(){
int i,x,j;
printf("Masukkan Angka Pertama : ");
scanf("%d",&i);
printf("Masukkan Angka Kedua : ");
scanf("%d",&x);
if(i>x){
printf("Angka %d Lebih Besar Dari %d",i,x);
}
else if(i<x){
printf("Angka %d Lebih Kecil Dari %d",i,x);
}
else {
printf("Error!");
}
}
- make declarations on the program
int i,x,j;
- This is to receive the first and second number input
printf("Masukkan Angka Pertama : ");
scanf("%d",&i);
printf("Masukkan Angka Kedua : ");
scanf("%d",&x);
- And this is the if and else condition to process the first and second number input
if(i>x){
printf("Angka %d Lebih Besar Dari %d",i,x);
}
else if(i<x){
printf("Angka %d Lebih Kecil Dari %d",i,x);
}
else {
printf("Error!");
}
- Save and Run.
- The C program is looping using FOR
#include
int main(){
int i;
for(i=1;i<=10;i++){
printf("\n%d Welcome Utopian-IO \n", i);
}
}
- Save And Run
- A simple C program uses While
#include
int main(){
int j;
j=1;
while(j<=10){
printf("%d",j);
j++;
}
}
- Save and Run
Merging several C programs to be compiled simultaneously
When finished we create three simple programs using C language, namely: - Programs distinguish small and large numbers, FOR loops, and WHILE programs.
Now it's time we combine all the above programs for the COMPILE simultaneously, see the programs I've combined below:
#include
int main(){
int i,x,j;
printf("Masukkan Angka Pertama : ");
scanf("%d",&i);
printf("Masukkan Angka Kedua : ");
scanf("%d",&x);
if(i>x){
printf("Angka %d Lebih Besar Dari %d",i,x);
}
else if(i<x){
printf("Angka %d Lebih Kecil Dari %d",i,x);
}
else {
printf("Error!");
}
for(i=1;i<=10;i++){
printf("\n%d Welcome Utopian-IO \n", i);
}
j=1;
while(j<=10){
printf("%d",j);
j++;
}
}
- Save And Run
And that's some simple C programming language and how to merge multiple programs in a single compile.
This tutorial is recommended for newly learned C programming languages, and is not recommended for advanced level.
Posted on Utopian.io - Rewarding Open Source Contributors