/* 程式檔名:test_2-34-1.c */
/* 程式目的:定義常數SIZE為10然後印出 */
/* 程式設計:蘇彥儒*/
/* 完成日期:20140205 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
const int SIZE=10;
printf("SIZE=%d \n",SIZE);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
==============================================
/* 程式檔名:test_2-34-2.c */
/* 程式目的:螢幕輸出三個宣告值 */
/* 程式設計:蘇彥儒*/
/* 完成日期:20130731 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
int a=10;
float b=101.7;
char c='c';
printf("a=%d \n",a);
printf("b=%.1f \n",b);
printf("c=%c \n",c);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
==============================================
/* 程式檔名:test_2-34-3.c */
/* 程式目的:計算矩形面積 */
/* 程式設計:蘇彥儒*/
/* 完成日期:20140205 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define head 10
#define wide 5;
void Pause(const char* message);
int main(int argc, char *argv[])
{
int area;
area=head*wide;
printf("矩形面積=%d \n",area);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
/* 程式目的:計算矩形面積 */
/* 程式設計:蘇彥儒*/
/* 完成日期:20140205 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define head 10
#define wide 5;
void Pause(const char* message);
int main(int argc, char *argv[])
{
int area;
area=head*wide;
printf("矩形面積=%d \n",area);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
==============================================
/* 程式檔名:test_2-34-4.c */
/* 程式目的:計算總和 */
/* 程式設計:蘇彥儒*/
/* 完成日期:20140205 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
printf("計算總和=%d \n",3+2);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
/* 程式目的:計算總和 */
/* 程式設計:蘇彥儒*/
/* 完成日期:20140205 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
printf("計算總和=%d \n",3+2);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
==============================================
/* 程式檔名:test_2-34-5.c */
/* 程式目的:計算相除的商(轉型) */
/* 程式設計:蘇彥儒*/
/* 完成日期:20140205 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
float n;
n=3.0/2;
printf("計算總和=%f \n",n);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
float n;
n=3.0/2;
printf("計算總和=%f \n",n);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
==============================================
/* 程式檔名:test_2-34-6.c */
/* 程式目的:計算相乘 */
/* 程式設計:蘇彥儒*/
/* 完成日期:20140205 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
int f;
f=1*2*3*4*5;
printf("計算總和=%d \n",f);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
int f;
f=1*2*3*4*5;
printf("計算總和=%d \n",f);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
==============================================
/* 程式檔名:test_2-34-7.c */
/* 程式目的:計算相乘除 */
/* 程式設計:蘇彥儒*/
/* 完成日期:20140205 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
float f;
f=5*2+1.0/10;
printf("計算總和=%f \n",f);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
float f;
f=5*2+1.0/10;
printf("計算總和=%f \n",f);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
==============================================
/* 程式檔名:test_2-34-8.c */
/* 程式目的:計算三個變數平均值*/
/* 程式設計:蘇彥儒*/
/* 完成日期:20130731 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
int a=95;
int b=74;
int c=81;
float d;
d=(a+b+c)/3.0;
printf("平均值=%f \n",d);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
int a=95;
int b=74;
int c=81;
float d;
d=(a+b+c)/3.0;
printf("平均值=%f \n",d);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
==============================================
/* 程式檔名:test_2-34-9.c */
/* 程式目的:交換數字*/
/* 程式設計:蘇彥儒*/
/* 完成日期:20140205 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
int a,b,c,temp;
a=10,b=20,c=30;
printf("交換前a=%d,b=%d,c=%d \n",a,b,c);
temp=a;
a=c;
c=b;
b=temp;
printf("交換後a=%d,b=%d,c=%d \n",a,b,c);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
int a,b,c,temp;
a=10,b=20,c=30;
printf("交換前a=%d,b=%d,c=%d \n",a,b,c);
temp=a;
a=c;
c=b;
b=temp;
printf("交換後a=%d,b=%d,c=%d \n",a,b,c);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
==============================================
/* 程式檔名:test_2-34-10.c */
/* 程式目的:利用ASCII轉換字母*/
/* 程式設計:蘇彥儒*/
/* 完成日期:20130731 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
char z='z';
char Z;
Z=z-32;
printf("小寫%c轉換成大寫%c \n",z,Z);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
#include <stdlib.h>
#include <string.h>
void Pause(const char* message);
int main(int argc, char *argv[])
{
char z='z';
char Z;
Z=z-32;
printf("小寫%c轉換成大寫%c \n",z,Z);
Pause("按 ENTER 繼續");
return EXIT_SUCCESS;
}
void Pause(const char* message)
{
printf("%s \n", message);
rewind(stdin);
getchar();
}
==============================================