網頁文章 javax.portlet.title.56

//林中誠 程式設計 20121002 功課一

#include
#include

int main()
{

short int no1=200; /* 宣告為短整數 */
int no2=200;
long int no3=200;
float no4=10.4;

printf("%d ",sizeof(no1)); /* 以10進位輸出 */
printf("%d ",sizeof(no2)); /* 以10進位輸出 */
printf("%d ",sizeof(no3)); /* 以10進位輸出 */
printf("%d ",sizeof(no4));

system("pause");
return 0;
}

 
//林中誠 程式設計 20121002 功課一
#include
#include

int main()
{
// char ch3=65;
char ch1='a';/* 宣告ch1為字元變數 */
char ch2[]="abcdfg";/* 宣告ch2為字串變數 */

printf("%d\n",sizeof(ch1));

printf("%d\n",sizeof(ch2));

printf("%c\n",ch2[0]);
printf("%c\n",ch2[1]);
printf("%c\n",ch2[2]);
printf("%c\n",ch2[3]);
printf("%c\n",ch2[4]);
printf("%c\n",ch2[5]);
printf("%c\n",ch2[6]);
printf("%c\n",ch2[5]);

printf("%s\n",&ch2[3]);

system("pause");
return 0;
}
 
//程式設計 20121002 功課二

#include
#include

int main()
{

short int s1=-1;/* 超過無號短整數的下限值 */
int s2=32768; /* 超過短整數的上限值 */


printf("s1=%d\n",s1);
printf("s2=%d\n",s2);

system("pause");
return 0;
}


 
//林中誠 程式設計 20121002 功課二
#include
#include

int main()
{

/* 四種字串宣告與設定初值模式 */
char Str_1[6]="Hello";
char Str_2[6]={ 'H', 'e', 'l', 'l','o','\0'};
char Str_3[ ]="Hello";
char Str_4[ ]={ 'H', 'e', 'l', 'l', 'o', '!' };


printf("------->>>>> %s %s\n",Str_1,&Str_1[0]);
printf("%s\n",Str_2);
printf("%s\n",Str_3);
printf("%s\n",Str_4);

system("pause");
return 0;
}

 
//程式設計 20121002 功課三

#include
#include

int main()
{

float f1=123.4568357109375F;/* 宣告單精數浮點數 */
float f2=21341372.1357912;/* 宣告八位數整數值的單精數浮點數 */
double d1=123456789.123456789123;/* 宣告倍精數浮點數 */

printf("f1=%f\n",f1);
printf("f2=%f\n",f2);
printf("d1=%f\n",d1);

system("pause");
return 0;
}

 
//林中誠 程式設計 20121002 功課三
#include
#include

int salary=17500;/* 宣告salary為全域變數 */

int main()
{
void show(void);

printf("salary=%d\n",salary);
{
int salary=22000;/* 在此宣告salary為區塊變數 */
printf("salary=%d\n",salary);
}
printf("salary=%d\n",salary);

show();


system("pause");
return 0;
}

void show(void)
{
printf("---->> %d\n",salary);
}