---
# System prepended metadata

title: '[QuiSwi Series] C language memo'

---

# [QuiSwi Series] C language memo

## New Repository
### Step1: new a folder of repository
### Step2: new a folder named ".vscode" in folder of repository
### Step3: build environment in ".vscode"
```cmd
git clone https://github.com/liaojason2/vscode-cpp-for-windows.git
```
#### Or put four files in ".vscode".

## Run in VScode
### New termainal
> ==Ctrl + Shift + `==

### Run build task
> ==Ctrl + Shift + B==

### Run .exe
```cmd
./<C file name>.exe
```

## Template
```c=
#include <stdio.h>

int main() {
  int num1, num2, sum;

  scanf("%d", &num1);
  scanf("%d", &num2);
  sum = num1 + num2;

  printf("%d \n", sum);

  return 0;
}
```

### Conditionals
```c=
#include <stdio.h>

int main() {
  int score;

  printf("Please enter your score: ");
  scanf("%d", &score);

  if (score >= 60)
    printf("You are pass! \n");
  else if (score >= 40)
    printf("You have a chance again! \n");
  else
    printf("You are fail! \n");

  return 0;
}
```

### Loop
```c=
#include <stdio.h>

int main() {
  int count1 = 1;
  int count2 = 1;
  int count3 = 1;
  int count4;

  // 1 while
  printf("\"while\" example \n");
  while (count1 < 4) {
    printf("%d \n", count1);

    count1++;
  }

  // 2 do while
  printf("\"do while\" example \n");
  do {
    printf("%d \n", count2);

    count2++;
  } while (count2 < 4);

  // 3 break and continue
  printf("\"break and continue\" example \n");
  while (count3 < 10) {
    if (count3 == 3) {  
        //  count3 = count3 + 1;
        count3++;

         continue;
    }

    if (count3 == 5)
      break;

    printf("%d \n", count3);

    count3++;
  }


  // 4 for
  printf("\"for\" example \n");
  for (count4 = 1; count4 < 4; count4++) {
    printf("%d \n", count4);
  }

  return 0;
}
```

ref:
[https://hackmd.io/@liaojason2/vscodecppwindows](https://hackmd.io/@liaojason2/vscodecppwindows)