PDA

ดูเวอร์ชั่นเต็ม : ด่วน ภาาา c ผิดตรงไหนอ่ะครับ



banzsmart
15th December 2013, 20:26
คือผมโง่วิชานี้มากเลยอ่ะครัีบ ช่วยที เหมือนมันบอกบรรทัด5ผิดนะ - -

#include<iostream.h>
#include<conio.h>
char na[20]="Siritripop";
int a,b,c,d,e,f,g
void main
{
clrscr();
cout<<na<<"\g";
cout<<"Enter wage:";
cin>>a;
cout<<"Enter day:";
cin>>b;
c = a*b;
cout<<j<<"g";
cout<<"Enter ot/dath:";
cin>>d; cout<<"Enter hour:";
cin>>e;
m = d*e;
cout<<f<<"\g";
g = c+f;
cout<<n<<"\g";
getch();
}

Artificial
15th December 2013, 21:16
ที่เห็นชัดๆก็บรรทัด 4 5 ผิดครับ

4: int a,b,c,d,e,f,g // ขาด Semicolon ';' หลังสุด

5: void main // ตรงส่วนนี้เป็นการ เขียนฟังก์ชัน รูปแบบของมันก็คือ RETURN_TYPE name( TYPE parameters, ... ) ซึ่งก็คือขาด ( ) ครับ
--> void main()

และก็ specifier (เครื่องหมาย \ตามด้วยตัวอักษร ) ตัว g ไม่มีน่ะครับ คาดว่าน่าจะหมายถึงการเว้นบรรทัด ก็ใช้เป็น \n นะครับ

สุดท้ายข้างในฟังก์ชัน ตรงๆก็ดูจะเขียนผิดนะครับ (ขาดตัวแปรหลายตัว/print ตัวแปรที่ยังไม่มีค่า) ก็ประกาศตัวแปรเพิ่มครับ
ก็ลองเขียนใหม่ดูนะครับ ดูเรื่องตัวแปรครับ

banzsmart
15th December 2013, 21:51
บอกตรงว่า ผมไม่รู้ไรกับวิชานี้จิงๆ ตอนนี้ผมเเก้ไปยังงี้เเล้วมันรันด้นะ ถูกเปล่าไม่รุ้ :sweat
#include<iostream.h>
#include<conio.h>
char na[20]="Siritripop";
int a,b,c,d,e,f,g ;
int main()
{
clrscr();
cout<<na<<"\n";
cout<<"Enter wage:";
cin>>a;
cout<<"Enter day:";
cin>>b;
c = a*b;
cout<<c<<"g";
cout<<"Enter ot/dath:";
cin>>d; cout<<"Enter hour:";
cin>>e;
f = d*e;
cout<<f<<"\n";
g = c+f;
cout<<g<<"\n";
getch();
}