Skip to content

Instantly share code, notes, and snippets.

@defrindr
Last active September 16, 2020 11:42
Show Gist options
  • Save defrindr/2226ca3f63fdca2827d557bc39a129bf to your computer and use it in GitHub Desktop.
Save defrindr/2226ca3f63fdca2827d557bc39a129bf to your computer and use it in GitHub Desktop.

Konsep Pemrograman

Installing codeblocks on ubuntu (maybe work in another distro too).

  1. Add PPA
sudo add-apt-repository ppa:codeblocks-devs/release
  1. Install Dependencies
sudo apt-get install build-essential 
  1. Installing codeblocks
sudo apt install codeblocks codeblocks-contrib

if you have error like in below, when you build program , try step 4

-------------- Build file: "no target" in "no project" (compiler: unknown)---------------

g++   -c /home/nightsec/Documents/Kuliah/KP/praktikum_1/main.cpp -o /home/nightsec/Documents/Kuliah/KP/praktikum_1/main.o
g++  -o /home/nightsec/Documents/Kuliah/KP/praktikum_1/main /home/nightsec/Documents/Kuliah/KP/praktikum_1/main.o  -lbgi-lgdi32-lcomdlg32-luuid-loleaut32-lole32  /home/nightsec/Documents/Kuliah/KP/Graphics-Library/libbgi.a
/usr/bin/ld: cannot find -lbgi-lgdi32-lcomdlg32-luuid-loleaut32-lole32
collect2: error: ld returned 1 exit status
  1. Remove default linker Settings -> Compiler -> Global Compiler Settings -> Linker Settings clear all link libraries and other linker options
#include <stdio.h>
int main()
{
// nilai awal :
// a = 1
// b = 2
// c = 3
// ekspektasi nilai :
// a = 4
// b = 3
// c = 5
int a=1, b=2, c=3, d;
// cetak setiap variable
printf("a = %d", a) ;
printf("b = %d", b) ;
printf("c = %d", c) ;
// nilai baru setiap element didapatkan
// dari element itu sendiri ditambahkan
// element dibelakang nya
// contoh :
// a = a+c
// b = b+a
// c = c+b
d = a;
// simpan dahulu nilai a kedalam
// variable dummy
// d = 1
a += c;
// a = a + c
// a = 1 + 3
b += d;
// b = b + d
// b = 2 + 1
c += b-d;
// c = c + b - c
// c = 3 + 3 - 1
// kenapa b - d ?? karena untuk mendapatkan
// nilai asli dari b kita harus menguranginya
// kembali dengan d
// cetak variable akhir
printf("\n");
printf("a = %d", a) ;
printf("b = %d", b) ;
printf("c = %d", c) ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment