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言語】変数

0
Posted at

【C言語】変数について

2日前からC言語の勉強始めました~~~~。
アウトプットしていこうと思います。

変数について

複雑な計算は変数を使う〇!
変数とは使いたい値に名前を付けたものです。

宣言とは

変数を使うにはを宣言ということをします。
宣言方法は、

データ型 変数;という書き方をします。

例) int x;
という感じです。

intとは整数を扱える型です。
なので、代入する値はすべて整数となります。

変数を使用するには、事前にデータ型と変数を宣言する必要があります!!

#include <stdio.h>

int main(void){
    /* ここで宣言 intはデータ型、 x,yは変数 */
    int x,y;
    /* x,y変数に値を代入 */
    x = 12;
    y = 15 - x;
    /* \nは改行 */
    printf("xの整数は%d\n", x);
    printf("yの整数は%d\n", y);
    /* return 0はプログラムが正常に終了したお知らせするもの */
    return 0;
}
xの整数は12
yの整数は3
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?