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言語忘備録2 基本文法

Last updated at Posted at 2022-10-10

printf scanfの指定子

%c char 文字
%s char* 文字列
%d int 整数
%f float 単精度浮動小数点数
%lf double 倍精度浮動小数点数

#include<stdio.h>
int main(void){
  char c,C[10];
  int n;
  double d;
  float f;
  scanf("%c %s %d %lf %f",&c,C,&n,&d,&f);
  printf("%c %s %d %f %f",c,C,n,d,f);
  return 0;
}

小数点桁数指定

#include<stdio.h>
int main(void){
    double a=10,b=3;
    printf("%.1lf %.2lf %.3lf",a/b,a/b,a/b);
    return 0;
}

結果 3.3 3.33 3.333
%.1の数字部分により小数第何位かが変わってくる。

unsigned long long int 最大値のデータ型

unsigned long long int a= 285212673;
printf("%llu", 285212672);

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?