PDA

ดูเวอร์ชั่นเต็ม : ใครเก่ง ภาษา C ดูให้หน่อยครับ



Sathienpong
18th July 2013, 21:25
ซึ้ง อยู่ที่โรงเรียนมันรันได้นะครับแต่อยู่บ้านรันไม่ได้สักที่เลย
ตอนอยู่โรงเรียน ใช้ windows 8 32bit โปรแกรม Turbo C++
บ้านผม windows 7 64 bit โปรแกรม Dev-C++ ลองใช่ Turbo C++ แล้วก็ไม่ได้เหมือนกัน

http://image.ohozaa.com/i/03e/v1NzG0.png

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d,e,ans;
printf("Please Enter Number");
printf("\nEnter Number a=");
scanf("%d",&a);

printf("\nEnter Number b=");
scanf("%d",&b);

printf("\nEnter Number c=");
scanf("%d",&c);

printf("\nEnter Number d=");
scanf("%d",&d);

printf("\nEnter Number e=");
scanf("%d",&e);

ans = (a+b+c+d+e)/5;
printf("\nAverage of number1-number5= %d",ans);

getch();
}


ช่วยหน่อยนะครับบบ

YAKAMA27
18th July 2013, 21:30
ผมใช้ codeblock อ่ะครับ ลองดู

spycommand
18th July 2013, 21:31
1.ลบ clrscr(); ออกครับ
2.ลบ void ออกจาก main

3.ในerror ทำไมมันมี gotoxy แต่ในโปรแกรมไม่มีเขียนไว้เลยอะครับ???

Price
18th July 2013, 21:33
เอาของผมไปดีกว่า

#include <stdio.h>
#include <conio.h>
main()
{
char province[50];
printf("Enter province name: ");
scanf ("%s",province);
printf("You stay in %s\n",province);
getch();
}

พิมพ์ชื่อจังหวัดไป

#‎include‬ <stdio.h>
#include <conio.h>
main ()
{
int hour,min;
printf ("input hour:");
scanf ("%d",&hour);
min = hour*60;
printf("mintute=%d",min);
getch();
}

พิมพ์ จำนวนเต็มไป มันจะแสดงเป็นนาที

#‎include‬ <stdio.h>
#include <conio.h>
main ()
{
int a,b,c,d,e,f,g;
a=20;
b=5;
c=a+b;
d=a-b;
e=a*b;
f=a/b;
g=a%b;
printf ("c=%d\n",c);
printf ("d=%d",d);
getch();
}

นี้แบบของ จขกท. นะ ผมเรียนมาเหมือนกัน

Sathienpong
18th July 2013, 21:33
1.ลบ clrscr(); ออกครับ
2.ลบ void ออกจาก main

3.ในerror ทำไมมันมี gotoxy แต่ในโปรแกรมไม่มีเขียนไว้เลยอะครับ???

ตอนทำในโรงเรียนก็รันได้ปกติอะ ทำไมอยู่บ้านมันมีปัญหาต่างกันอะครับ

spycommand
18th July 2013, 21:36
ตอนทำในโรงเรียนก็รันได้ปกติอะ ทำไมอยู่บ้านมันมีปัญหาต่างกันอะครับ

ผมก็ไม่ทราบครับ 55 (ได้รึยังครับ???)

edit :
dev c++ ไม่มีฟังก์ชัน clrscr(); เหมือนใน turbo c++ครับ
(ตอนแรกลืมอ่านว่าที่ รรใช้ turbo c++)

Sathienpong
18th July 2013, 21:39
ผมก็ไม่ทราบครับ 55 (ได้รึยังครับ???)
ได้แล้วครับบ ^ ^