Jumat, 24 April 2020

SQL: statements

select * Customers: select or get every colomn from Customers table


Support 5 major command (S,U,D,I,W): Select, Update, Delete, Insert and Where.



select:
1. select column1, column2
from testing_table;

Rabu, 22 April 2020

CPP: Structure

Hi, CPP Programmer, welcome.

Structure vs array

Structure are different types value. Array are the same type value.

Structure consist of:
1. Structure variable
2. Structure tag
3. Structure member

Defining structure tag is optional.
Defining member is just like the defining variable.

Basic structure use are below:
#include <iostream>
#include <cstring>

using namespace std;

//1.Create the structure
struct Books{
char title[50];
char author[50];
char subject[50];
int book_id;
};



int main()
{
//2. Declare Book1 of type Books
struct Books Book1;
struct Books Book2;


//3. Define book Book1 specification
strcpy( Book1.title, "Learn C++ Programming");
strcpy( Book1.author, "Chand Miyan");
strcpy( Book1.subject, "C++ Programming");
Book1.book_id = 6495407;

//4. Define book Book2 specification
strcpy( Book1.title, "Telecom Billing");
strcpy( Book2.author, "Yakit Singha");
strcpy( Book2.subject, "Telecom");
Book2.book_id = 6495700;

//5. Print out Book1 info
cout << "Book 1 title: " << Book1.title << endl;
cout << "Book 1 author: " << Book1.author << endl;
cout << "Book 1 subject: " << Book1.subject << endl;
cout << "Book 1 book id: " << Book1.book_id << endl;

//6. Print
cout << "Book 1 title: " << Book1.title << endl;
cout << "Book 1 author: " << Book1.author << endl;
cout << "Book 1 subject: " << Book1.subject << endl;
cout << "Book 1 book id: " << Book1.book_id << endl;

}


Sending structure variable pointer to a function is almost the same as sending the struct variable to the function, the difference is: if you use structure variable pointer you use asterix and you need to declare a structure variable pointer.

Senin, 20 April 2020

SMALL BASIC: Printing stars

Hi, SMALL BASIC programmer, welcome.

In this tutorial, we will discus about variety of printing stars or asteriks.
1. Incremented stars
num_of_row = 10
For i = 0 To num_of_row
  For j = 0 To i
    TextWindow.Write("* ")
  EndFor
  TextWindow.WriteLine("")
EndFor

Output:



2. Reversed incremented (decremented stars)
num_of_row = 10
For i = num_of_row To 0 Step -1
  For j = 0 To i
    TextWindow.Write("* ")
  EndFor
  TextWindow.WriteLine("")
EndFor


 


Or, you can combine step 1 and step 2 into one program, like below:

num_of_row = 10
For round = 0 To 100
For i = 0 To num_of_row
  For j = 0 To i
    TextWindow.Write("* ")
  EndFor
  TextWindow.WriteLine("")
EndFor
'TextWindow.WriteLine("Ok, sukses atas")

Program.delay(1000)
TextWindow.Clear()
For i = num_of_row To 0 Step -1
  For j = 0 To i
    TextWindow.Write("* ")
  EndFor
  TextWindow.WriteLine("")
EndFor
Program.Delay(1000)
TextWindow.Clear()
EndFor


3. The decremented space
num_of_row = 10

For i = 1 To num_of_row
  For j = 1 To num_of_row - i 
    TextWindow.Write("  ")
  EndFor
  For k = 1 To i
    TextWindow.Write("* ")
  EndFor
  TextWindow.WriteLine(" ")
EndFor

Output:



4. The last the increment space
num_of_row = 10

For i = 1 To num_of_row 
  For j = 1 To i
    TextWindow.Write("  ")
  EndFor
  For k = 1 To num_of_row - i 'the rest of colomn
    TextWindow.Write("* ")
  EndFor
  TextWindow.WriteLine(" ")
EndFor

Output:


5. The last, I don't know what to call this, but I call this cool stars
num_of_row = 10

For i = 1 To num_of_row
  For j = 1 To num_of_row - i 
    TextWindow.Write("  ")
  EndFor
  For k = 1 To num_of_row - 1
    TextWindow.Write("* ")
  EndFor
  TextWindow.WriteLine(" ")
EndFor


6. I don't know what to call this, but I call this smooky stars
num_of_row = 10

For i = 1 To num_of_row
  For j = 1 To num_of_row - i 
    TextWindow.Write("  ")
  EndFor
  For k = 1 To j
    TextWindow.Write("* ")
  EndFor
  TextWindow.WriteLine(" ")
EndFor

Minggu, 19 April 2020

SMALL BASIC: Algorithm to download webpage from the internet

Hello, SMALL Basic programmer, welcome.

You know that you can download webpage from the internet using SMALL basic?

This is the algorithm:
1. Ask user about the link of the web page.
2. Download the webpage.
3. Print out the result of the step 2 to the screen, or
4. Ask the user about the folder to save the file to (optionally).
5. Save it to a file on local directory (optionally).

This is the code:
'Ask
TextWindow.WriteLine("1. What page do you like to traverse? Use https:// or http:// ")
wp = TextWindow.Read()

'Get the webpage (wp)
'gwp = Network.GetWebPageContents("www.facebook.com/katakatalelucondanlucu")
'gwp = Network.GetWebPageContents("https://corona.jakarta.go.id/id")

gwp = Network.GetWebPageContents(wp)
TextWindow.Write(gwp)

TextWindow.WriteLine("2. (Optional) Tell me, what is the folder you want the web page saved to, for instance C:\Users\Totzfreelance\mywebpage.html:")
folder = TextWindow.Read()

File.WriteContents(folder,gwp)



   
  

SMALL BASIC: Printing out String a letter by a letter

a = "AAAAAA"
For i = 1 To Text.GetLength(a)
  TextWindow.WriteLine(text.GetSubText(a,i,1))
EndFor
  

Journey to find Gog and Magog

Fact
1. Gog and magog mentioned twice in the bible:



and will go out to deceive the nations in the four corners of the earth—Gog and Magogand to gather them for battle. In number they are like the sand on the seashore.







2. Ezekiel prophet was born 621 BC. Live in the ancient Israel.
3. Babylonian Kingdom exist in the time Ezekiel mentioned Gog and Magog

Jumat, 17 April 2020

IPv4 Activity

Basic:
1. Binary to decimal conversion activity
For example:
Enter the decimal of this binary: 00110111
Decimal is: 55

2. Decimal to binary conversion activity
For example:
Enter the binary of this decimal: 241
The binary is: 11110001

3. Given address/prefix 144.97.144.28/23
Determine:
1. Network address,
1.1. Last octet in binary
1.2 Last octet in decimal
1.3 Enter full address in decimal

2. Broadcast address
2.1 Last octet in binary
2.2 Last octet in decimal
2.3 Enter full address in decimal

3. First usable host address
3.1 Enter last octet in binary
3.2 Enter last octet in decimal
3.3 Enter the full address in decimal

4. Last Usable Host Address
4.1 Enter Last octet in binary
4.2 Enter Last octet in decimal
4.3 Enter full address in decimal





To remember this: NAHAMA.

NA = Network address
HA = Host Address
FHA = First host address
LHA = Last host address
HBA = Host Broadcast Address
SMA = Subnet Mask Address


1. Determining network address in decimal and in binary of a pair host address and mask address.

For example:
Host address: 10.158.30.81
Subnet Mask: 255.255.224.0


Solution: Anding both each host octet and respective subnetmask octet.

You can watch how the solution is in this video:




2. Determining the number of host

The solution is: (2 ^ number of bit 0 in the subnetmask in binary form) - 2.

You can watch how to solve it easily in this video:




3. Determining First Usable Host (FUH), Last Usable Host (LUH), Broadcast address in Decimal (BAD), and Next Network in decimal (NND)

First Usable Host (FUH)
1. Get all bit 0 in subnetmask in binary
2. Increment 1 to last octet.

Last Usable Host (LUH)
1. Get all the 0 bits of subnetmask in binary.
2. Make 1 all except the Less Significant bit (LSB).
3. Divide the bits of step 2 per octet.
4. Increment each octet value to each octet of network address in decimal.

Broadcast address in Decimal
1. Get all the 0 bits subnetmask in binary
2. Make 1 all
3. Divide the bits of step 2 per octet
4. Increment each octet value to each octet of network address in decimal.

Next Network in decimal (NND)
1.
2.
3.