1 #include <stdio.h> 2 3 int main(void) 4 { 5 6 printf("-------------------------------------\n"); 7 printf("Akita National College of Technology\n"); 8 printf("秋田工業高等専門学校\n"); 9 printf("\n"); 10 printf("Yamamoto Masashi\n"); 11 printf("山本昌志\n"); 12 printf("-------------------------------------\n"); 13 14 return 0; 15 }
1 #include <stdio.h> 2 3 int main(void) 4 { 5 6 printf("--------------------------------\n"); 7 printf("補助\t読み方\t値\n"); 8 printf("================================\n"); 9 printf("p\tピコ\t0.000000000001\n"); 10 printf("n\tナノ\t0.000000001\n"); 11 printf("m\tミリ\t0.001\n"); 12 printf("k\tキロ\t1000\n"); 13 printf("M\tメガ\t1000000\n"); 14 printf("G\tギガ\t1000000000\n"); 15 printf("--------------------------------\n"); 16 17 return 0; 18 }
1 #include <stdio.h> 2 3 int main(void) 4 { 5 int a, b, c, d, e, f, g; 6 7 a=543; 8 b=123; 9 10 c=a+b; 11 d=a-b; 12 e=a*b; 13 f=a/b; 14 g=a%b; 15 16 printf("%d + %d = %d\n",a,b,c); 17 printf("%d - %d = %d\n",a,b,d); 18 printf("%d * %d = %d\n",a,b,e); 19 printf("%d / %d = %d\n",a,b,f); 20 printf("%d %% %d = %d\n",a,b,g); 21 22 return 0; 23 }
543 + 123 = 666 543 - 123 = 420 543 * 123 = 66789 543 / 123 = 4 543 % 123 = 51
1 #include <stdio.h> 2 3 int main(void) 4 { 5 int one, five, ten, fifty, total; 6 7 printf("1円玉の枚数?\t"); 8 scanf("%d",&one); 9 10 printf("5円玉の枚数?\t"); 11 scanf("%d",&five); 12 13 printf("10円玉の枚数?\t"); 14 scanf("%d",&ten); 15 16 printf("50円玉の枚数?\t"); 17 scanf("%d",&fifty); 18 19 total = one+5*five+10*ten+50*fifty; 20 printf("合計金額は,%d円です.\n",total); 21 22 return 0; 23 }
1 #include <stdio.h> 2 3 int main(void) 4 { 5 double R1, R2, R3, Ra, Rb; 6 7 printf("R1の抵抗?\t"); 8 scanf("%lf",&R1); 9 10 printf("R2の抵抗?\t"); 11 scanf("%lf",&R2); 12 13 printf("R3の抵抗?\t"); 14 scanf("%lf",&R3); 15 16 Ra=R1*R2/(R1+R2)+R3; 17 Rb=R1+R2*R3/(R2+R3); 18 19 printf("回路(a)の合成抵抗は,%fオームです.\n",Ra); 20 printf("回路(b)の合成抵抗は,%fオームです.\n",Rb); 21 22 return 0; 23 }
1 #include <stdio.h> 2 #include <math.h> 3 4 int main(void) 5 { 6 double s, r; 7 8 printf("円の面積?\t"); 9 scanf("%lf",&s); 10 11 r=sqrt(s/M_PI); 12 printf("半径は,%fです.\n",r); 13 14 return 0; 15 }
1 #include <stdio.h> 2 #include <math.h> 3 4 int main(void) 5 { 6 double deg, rad, x; 7 8 printf("角度?\t"); 9 scanf("%lf",°); 10 11 rad=deg/180.0*M_PI; 12 13 x=sqrt(0.57*0.57+0.3*0.3-2.0*0.57*0.3*cos(rad)); 14 printf("xは,%fです.\n",x); 15 16 return 0; 17 }