0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

C言語忘備録 ~基本構文

Last updated at Posted at 2022-10-08

基本構文

#include <stdio.h>
int main(void){
    printf("HelloWorld");
    return 0;
}

文字の出力
printf("~~~~");
計算結果の表示
printf("%d",1+1);

数字の入力

#include <stdio.h>
int main(void){
    int number;
    scanf("%d",&number);
    printf("%d",number);
    return 0;
}

小数扱い方

#include <stdio.h>
int main(void){
    double x;
    x = 9.99;
    printf("%f",x);
}

for文

#include <stdio.h>
int main(void){
  int i;
  for(i=0; i<=5; i++){
      printf("%d\n", i);
  }
}

多重ループ

#include <stdio.h>
int main(void){
  int i,j,width=7,height=7;
  for(i=1; i<=height; i++){
      for(j=1; j<=width; j++){
          printf("*");
      }
      printf("\n");
  }
}

配列

#include <stdio.h>
int main(void){
    int i;
    int num[10];
    for(i=0; i<10; i++){
        num[i] = i*2;
        printf("%d\n",num[i]);
    }
    return 0;
}

関数

再帰

文字列の配列

ポインタ

構造体

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?