บทที่ 6

แนะนำ สอบถาม ภาษา C สำหรับผู้เริ่มต้น ภาษา Java ภาษา Python

Moderators: mindphp, ผู้ดูแลกระดาน

User avatar
icphysics
PHP Full Member
PHP Full Member
Posts: 38
Joined: 01/01/1970 7:00 am
Contact:

บทที่ 6

Post by icphysics » 27/09/2004 7:49 pm

/*บทที่ 6 ข้อ 6.ก*/
#include<stdio.h>
void main()
{
int k=0;
while(k++ <=20)
printf("\tk=%3d \n",k);
printf(" befor while loop k===%3d\n",k);
}

/* ตอบ k=21 */

User avatar
icphysics
PHP Full Member
PHP Full Member
Posts: 38
Joined: 01/01/1970 7:00 am
Contact:

Post by icphysics » 27/09/2004 7:51 pm

/* ข้อ บทที่ 6 ข้อ 6ข */
#include<stdio.h>
void main()
{
int k=0;
while(++k <=20)
printf("\tk=%3d \n",k);
printf(" befor while loop k===%3d\n",k);
}
/* ค่า k=20*/

User avatar
icphysics
PHP Full Member
PHP Full Member
Posts: 38
Joined: 01/01/1970 7:00 am
Contact:

Post by icphysics » 27/09/2004 7:52 pm

/* ข้อ บทที่ 6 ข้อ 6ค */
#include<stdio.h>
void main()
{
int k=0,w;
for(k=0,w=k++;k<20;++k)
printf("\tk=%3d \n",k);
printf(" befor for loop k===%3d\n",k);
}
/* ค่า k=20*/

User avatar
icphysics
PHP Full Member
PHP Full Member
Posts: 38
Joined: 01/01/1970 7:00 am
Contact:

Post by icphysics » 27/09/2004 7:55 pm

/*ข้อ บทที่ 6 ข้อ 6ง */
#include<stdio.h>
void main()
{
int k=0;
do {
printf("\t befor k++ k=%3d \n",k);
++k;
printf("\tk=%3d \n",k);
}
while (k++<20);

printf(" befor for loop k===%3d\n",k);
}
/*total= 55
k=11
*อ

User avatar
icphysics
PHP Full Member
PHP Full Member
Posts: 38
Joined: 01/01/1970 7:00 am
Contact:

Post by icphysics » 27/09/2004 7:57 pm

/* ข้อ บทที่ 6 ข้อ 6จ */
#include<stdio.h>
void main()
{
int k=0,total;
for(total=0,k=1;k<=10;total+=k++)
printf("\tk=%3d \n",k);
printf("\total =%3d \n",total);
printf(" befor for loop k==%3d\n",k);
}
/* total =55
k=11
*/

User avatar
icphysics
PHP Full Member
PHP Full Member
Posts: 38
Joined: 01/01/1970 7:00 am
Contact:

Post by icphysics » 27/09/2004 8:01 pm

/*บทที่ 6 ข้อ 7 */
/*เขียนใหม่เป็นดังนี้*/
while((chr=getchar())!='\n')
{
if(chr!=chr)
contunue;
putchar(chr);
}

Post Reply

Return to “Programming - C/C++ & java & Python”

Who is online

Users browsing this forum: No registered users and 37 guests