C语言实验报告

C语言实验报告
C语言实验报告

《程序设计基础》实验报告

?scanf_s(”%f", &a);

b = a*K;

printf_s(”the current price of TV:");

?printf_s("%f", b);

return 0;

2。

#include"stdafx.h”

int main()

?int a, b, c, d, e, f;

?printf_s("please inputthree figures:"); ?scanf_s("%d", &a);

?b = a / 100;

?c = a %100;

?d = c / 10;

e= c % 10;

f = e * 100 + d * 10 + b;

printf_s(”the new three figures:”);

?printf_s(”%d”, f);

return 0;

}

3、

#include"stdafx。h"

int main()

floata, b, c, d, e;

printf_s("please input scores:\n”);

?scanf_s(”%f%f%f”, &a, &b, &c);

d = a + b + c;

e = (a + b+ c) / 3;

printf_s("the total scores:");

?printf_s(”%5.1f\n”, d);

?printf_s(”the average scores:”);

?printf_s("%4、1f\n”, e);

return 0;

}

4、

#include"stdafx.h"

int main()

{

?floata, b;

?printf(”please input a number:");

?scanf_s("%f", &a);

printf_s("the integer part is:");

?printf_s("%d\n", (int)a);

?b = a - (int)a;

?printf_s(”the decimalpart is:”); ?printf_s("%2.1f", b);

return 0;

}

5、

#include"stdafx。h”

intmain()

{

intx, d, s;

x = 298;

d = x / 60;

?s = x % 60;

?printf_s("the minnutes is:");

printf_s("%d\n", d);

printf_s(”the seconds is:”);

printf_s("%d", s);

return 0;

}

相关主题
相关文档
最新文档