#include <stdio.h>
int main()
{
int a = 3;
int b = 5;
int c;
c = a + b;
printf("a=%d b=%d a+b=%d \n",a,b,c);
return 0;
}
執行結果:
a=3 b=5 a+b=8
說明:
#include <stdio.h>
int main()
{
int a = 3; //設一個整數(int),這個整數叫a,把3給a
int b = 5; //設一個整數,叫b,把5給b
int c; //設一個整數,叫c,沒有預設值
c = a + b; //把a+b給c
printf("a=%d b=%d a+b=%d \n",a,b,c); //列印出a=?b=?a+b=?其中a=%d的%d代表後面a的值,d為整數,依次b=後面b的值,a+b=後面c的值
return 0; //歸零
}