4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

Create multiple C language programs in one compile

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 <stdio.h>
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.

image.png

  • The C program is looping using FOR
#include <stdio.h>
int main(){
	
	int i;
		
	for(i=1;i<=10;i++){
		
		printf("\n%d Welcome Utopian-IO \n", i);
		
	}		
}
  • Save And Run

image.png

  • A simple C program uses While
#include <stdio.h>
int main(){
	
	int j;
	j=1;
	while(j<=10){
		
		printf("%d",j);
		j++;
		
	}		
}
  • Save and Run

image.png

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 <stdio.h>
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

image.png

  • 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

0 upvotes $0.00

Replies (3)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: