ช่วยดูโค้ดให้หน่อยครับมัน error ไม่รู้จะแก้ยังไงดี
#include<stdio.h> #include<conio.h> #include<stdlib.h> #include <stdio.h> #include <math.h> #include <iostream> #include <cctype>
int endselect() { printf("Prease any key to back to main menu.\r\n"); getch(); return 0; }
int select1() { system("cls"); int number; int i; printf("Enter number : "); scanf("%d", &number); for(i = 1; i<=12;i++){ printf("%d x %d = %d\n", number, i, number*i); } return 0; } int select2() { system("cls"); int salary ; float vat,allpay ;
printf("Enter yr salary:"); scanf("%d",&salary); if (salary<5000) { vat=0; } else if (salary>=5000 && salary<=9999) { vat=salary*0.05; } else if (salary>=10000 && salary<=19999) { vat=salary*0.07; } else if (salary>20000) { vat=salary*0.10; } printf(" Vat = %.1f Bath\n",vat); allpay = salary+vat; printf(" AllPay = %.1f Bath\n",allpay);
return 0; }
int select3() { system("cls"); using namespace std;
void getColorCode(char colorCode[]); long getResistorValue(char colorCode[]);
char colorCode[3];
void main (int) { <<<<< [บรรทัดที่ 71 error] long r_value = 0; printf("This program will calculate the value of a resistor.\n\n"); printf("B = Black\nN = Brown\nR= Red\nO = Orange\nY = Yellow\n"); printf("G = Green\nL = Blue\nV = Violet\nE = Gray\nW = White\n\n"); printf("Enter the 4-character color description of the resistor: "); getColorCode(colorCode);
r_value = getResistorValue(colorCode); printf("\n\nThe resistor with color code %c %c %c has a value of %d Ohms.\n", colorCode[0], colorCode[1], colorCode[2], r_value); return 0; }
void getColorCode(char colorCode[]) { int i; for(i = 0; i < 4; i++) colorCode[i] = getchar(); }
long getResistorValue( char colorCode[] ) {
int i; double multiplier; char band_color; long value; int colorValue[3];
for(i = 0; i < 3; i++) { band_color = toupper(colorCode[i]); switch (band_color) { case('B'): colorValue[i] = 0; break; case('N'): colorValue[i] = 1; break; case('R'): colorValue[i] = 2; break; case('O'): colorValue[i] = 3; break; case('Y'): colorValue[i] = 4; break; case('G'): colorValue[i] = 5; break; case('L'): colorValue[i] = 6; break; case('V'): colorValue[i] = 7; break; case('E'): colorValue[i] = 8; break; case('W'): colorValue[i] = 9; break; default: printf("\nERROR: Color Code %c is not a valid choice\n", colorCode[i]); break; } } multiplier = pow( 10, (double) colorValue[2]); value = (((colorValue[0]*10) + colorValue[1]) * multiplier); return value; }
int menu()
return 0; } <<<<<<[แจ้งเตือนบรรทัดนี้] int main() { <<<<<<[บรรทัดmuj 154 error] char quit; int select,chk; while(quit != 'y') { system("CLS"); printf("#############################\r\n"); printf("### Menu ###\r\n"); printf("1. Sudkoon\r\n"); printf("2. Calculate Tax\r\n"); printf("3. Calculate Resistor\r\n"); printf("Or other key to exit program\r\n"); printf("Select number(1-3) : "); select = getch(); printf("\r\n"); chk = 0; if(select == '1') { chk = select1(); } if(select == '2') { chk = select2(); } if(select == '3') { chk = select3(); } if(chk == 0) { printf("Do you want to exit program ? (y or n) : "); quit = getch(); } } return 0; }
มันerror 2 จุดอะครับ บรรทัดที่ 71 แล้วก็ บรรทัดที่ 154
บรรทัดที่ 71 error แบบนี้ครับ 71: Declaration syntax error in function select3() บรรทัดที่ 154 154: Cannot overload 'main' บรรทัดที่ 151 ขึ้นแจ้งเตือน 151: Function should return a value in function select3()
|