## บทที่ 7 (function (d, s, id) { var js, fjs = d.getElementsByTagName(s); if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_EN/sdk.js#xfbml=1&version=v2.3&appId="; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));

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

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

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

### บทที่ 7

/* บทที่ 7 ข้อ 3 */
#include<stdio.h>
#include<math.h>
void main()
{
int i,j,k;
long x,t2,t3=1;
k=0;
t2=3;
while(t2<=300)
{
t2+=2;
x=sqrt(t2);
for(i=3;i<=x;i+=2)
if((i=t2%i)==0)
{
break;
}
if(k==0)
{
if(t2-t3<=2)
printf("the twin prine number are %d and %d \n",t2,t3);
t3=t2;
}
}
}

icphysics
PHP Full Member Posts: 38
Joined: 01/01/1970 7:00 am
Contact:
/* บทที่ 7 ข้อ 1 ก */
#include<stdio.h>
void main()
{
int i=0,j=10,x=0;
int num;
printf("Enter number \n");
while(i<10)
{
scanf("%d",&num);
++i;
}
printf("\n number less 0 is \t " );
while(x<j)
{
if(num[x]<0)
{
printf(" %d \t ",num[x]);
}
++x;
}

}

icphysics
PHP Full Member Posts: 38
Joined: 01/01/1970 7:00 am
Contact:
/* บทที่ 7 ข้อ 1 ข */
#include<stdio.h>
void main()
{
int i=0,j=10,x=0;
int num;
printf("Enter number \n");
while(i<10)
{
scanf("%d",&num);
++i;
}
printf("\n number add 0 is \t " );
while(x<j)
{
if(num[x]>0)
{
printf(" %d \t ",num[x]);
}
++x;
}

}

icphysics
PHP Full Member Posts: 38
Joined: 01/01/1970 7:00 am
Contact:
/* บทที่ 7 ข้อ 1 ค */
#include<stdio.h>
void main()
{
int i=0,j=10,x=0 ,sum=0;
int num;
printf("Enter number \n");
while(i<10)
{
scanf("%d",&num);
++i;
}
while(x<j)
{
if(num[x]<0)
{
sum+=num[x];
}
++x;
}
printf("\n sum value < 0 is %d \t ",sum);
}

icphysics
PHP Full Member Posts: 38
Joined: 01/01/1970 7:00 am
Contact:
/* บทที่ 7 ข้อ 1 ง */
#include<stdio.h>
void main()
{
int i=0,j=10,x=0,sumd=0;
int num;
printf("Enter number \n");
while(i<10)
{
scanf("%d",&num);
++i;
}
while(x<j)
{
if(num[x]%2=0)
{
sumd=num[x];
}
++x;
}
printf("\n sum value/2= is %d \t ",sumd);
}

icphysics
PHP Full Member Posts: 38
Joined: 01/01/1970 7:00 am
Contact:
/* บทที่ 7 ข้อ 1 จ */
#include<stdio.h>
void main()
{
int i=0,j=10,x=0,sume=0;
int num;
printf("Enter number \n");
while(i<10)
{
scanf("%d",&num);
++i;
}
while(x<j)
{
if((num[x]%2)!=0)
{
sume+=num[x];
}
++x;
}
printf("\n sum value/2= is %d \t ",sume);
}

icphysics
PHP Full Member Posts: 38
Joined: 01/01/1970 7:00 am
Contact:
/* บทที่ 7 ข้อ 5 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void main()
{
unsigned long lnumber;
char string;
scanf("%ld",&lnumber);
ultoa(lnumber,string,10);
printf("string = %d unsigned long = %lu\n",strlen(string),lnumber);
strrev(string);
printf("rever = %s \n",string);
}

### Who is online

Users browsing this forum: No registered users and 32 guests