Programming 2

I created a program that allows a user to input two values and display the sum of them.



The code:
#include <stdio.h>

int main (void)
{
int a, b, c;

puts("2つの整数を入力してください。");

/*putsっていうのはprintfに改行を加えたものとほとんど同じでもカッコ内にはひとつの実引数しか入れられない!*/

printf("整数1:"); scanf("%d", &a); /*整数を入力させる*/
printf("整数2:"); scanf("%d", &b);

printf("それらの和は%d", a+b); /*和の表示*/

return(0);
}

0 件のコメント:

コメントを投稿