help me with this coding =)
#include <stdio.h> #include <string.h> int passanger(); void intro(int x); int main () { int password,x; char email[10],name[10],address[10]; int user, ic,phone,from,to,c,confirm_password; float price; intro(x); printf ("\n1- Current User"); printf ("\n2- New User"); printf ("\n\nwho are You??"); printf ("\n"); scanf ("%d",&user); system("cls"); if (user==1) { int x; intro(x); printf ("\n\nLOGIN "); printf("\nEmail : "); scanf("%s",email); system("cls"); intro(x); printf("\nPassword: "); scanf("%d",&password); system("cls"); } else if (user==2) { int x; intro(x); printf("\nREGISTRATION"); printf ("\n\nName:"); scanf (" %s",&name); system("cls"); intro(x); printf ("\n\nIC No:"); scanf (" %d",&ic); system("cls"); intro(x); printf ("\n\nPassword:"); scanf("%d",&password); system("cls"); intro(x); printf ("\n\nConfirm Password:"); scanf("%d",&confirm_password); system("cls"); while (confirm_password !=password) { int x; intro(x); printf ("\n\nplease Confirm Password again:"); scanf("%d",&confirm_password); system("cls"); } intro(x); printf ("\n\nEmail:"); scanf (" %s", &email); system("cls"); intro(x); printf ("\n\nAddress:"); scanf (" %s", &address); system("cls"); intro(x); printf ("\n\nPhone No:"); scanf (" %d", &phone); system("cls"); } else printf ("Please enter 1 or 2 only!!"); //printf("Name :%s\n",name); //printf("IC No :%d\n",ic); // printf("Password :%d\n",password); // printf("Email :%s\n",email); //printf("Address :%s\n",address); // printf("Phone :%d\n",phone); do { int x; intro(x); printf ("I'm Booking\n\n""Choose your destination (enter the number 1-5 only)\n\n"); printf("1-Lapangan Terbang Antarabangsa Kuala Lumpur\n"); printf("2-Lapangan Terbang Sultan Abdul Halim\n"); printf("3-Lapangan Terbang Sultan Haji Ahmad Shah\n"); printf("4-Lapangan Terbang Antarabangsa Senai\n"); printf("5-Lapangan Terbang Sultan Ismail Petra\n"); printf("\n\tFrom=>"); scanf("%d",&from); printf("\tTo =>"); scanf("%d",&to); printf("\n________________\n"); printf("1-proceed 2-edit\n"); printf("----------------\n"); scanf("%d",&c); system("cls"); }while(c==2); if(from==1&&to==2) { int x,y; float price; intro(x); printf("depart\n\tLapangan Terbang Antarabangsa Kuala Lumpur\n\nto\n\tLapangan Terbang Sultan Abdul Halim\n"); passanger(y); } else if(from==2&&to==1) { int x; intro(x); printf("depart\n\tLapangan Terbang Sultan Abdul Halim\n\nto\n\tLapangan Terbang Antarabangsa Kuala Lumpur"); } else if(from==1&&to==3) { int x; intro(x); printf("depart\n\tLapangan Terbang Antarabangsa Kuala Lumpur\n\nto\n\tLapangan Terbang Sultan Haji Ahmad Shah"); } else if(from==3&&to==1) { int x; intro(x); printf("depart\n\tLapangan Terbang Sultan Haji Ahmad Shah\n\nto\n\tLapangan Terbang Antarabangsa Kuala Lumpur"); } else if(from==1&&to==4) { int x; intro(x); printf("depart\n\tLapangan Terbang Antarabangsa Kuala Lumpur\n\nto\n\tLapangan Terbang Antarabangsa Senai"); } else if(from==4&&to==1) { int x; intro(x); printf("depart\n\tLapangan Terbang Antarabangsa Senai\n\nto\n\tLapangan Terbang Antarabangsa Kuala Lumpur"); } else if(from==1&&to==5) { int x; intro(x); printf("depart\n\tLapangan Terbang Antarabangsa Kuala Lumpur\n\nto\n\tLapangan Terbang Sultan Ismail Petra"); } else if(from==5&&to==1) { int x; intro(x); printf("depart\n\tLapangan Terbang Sultan Ismail Petra\n\nto\n\tLapangan Terbang Antarabangsa Kuala Lumpur"); } else if(from==2&&to==3) { int x; intro(x); printf("depart\n\tLapangan Terbang Sultan Abdul Halim\n\nto\n\tLapangan Terbang Sultan Haji Ahmad Shah"); } else if(from==3&&to==2) { int x; intro(x); printf("depart\n\tLapangan Terbang Sultan Haji Ahmad Shah\n\nto\n\tLapangan Terbang Sultan Abdul Halim"); } else if(from==2&&to==4) { int x; intro(x); printf("depart\n\tLapangan Terbang Sultan Abdul Halim\n\nto\n\tLapangan Terbang Antarabangsa Senai"); } else if(from==4&&to==2) { int x; intro(x); printf("depart\n\tLapangan Terbang Antarabangsa Senai\n\nto\n\tLapangan Terbang Sultan Abdul Halim"); } else if(from==2&&to==5) { int x; intro(x); printf("depart\n\tLapangan Terbang Sultan Abdul Halim\n\nto\n\tLapangan Terbang Sultan Ismail Petra"); } else if(from==5&&to==2) { int x; intro(x); printf("depart\n\tLapangan Terbang Sultan Ismail Petra\n\nto\n\tLapangan Terbang Sultan Abdul Halim"); } else if(from==3&&to==4) { int x; intro(x); printf("depart\n\tLapangan Terbang Sultan Haji Ahmad Shah\n\nto\n\tLapangan Terbang Antarabangsa Senai"); } else if(from==4&&to==3) { int x; intro(x); printf("depart\n\tLapangan Terbang Antarabangsa Senai\n\nto\n\tLapangan Terbang Sultan Haji Ahmad Shah"); } else if(from==3&&to==5) { int x; intro(x); printf("depart\n\tLapangan Terbang Sultan Haji Ahmad Shah\n\nto\n\tLapangan Terbang Sultan Ismail Petra"); } else if(from==5&&to==3) { int x; intro(x); printf("depart\n\tLapangan Terbang Sultan Ismail Petra\n\nto\n\tLapangan Terbang Sultan Haji Ahmad Shah"); } else if(from==4&&to==5) { int x; intro(x); printf("depart\n\tLapangan Terbang Antarabangsa Senai\n\nto\n\tLapangan Terbang Sultan Ismail Petra"); } else if(from==5&&to==4) { int x; intro(x); printf("depart\n\tLapangan Terbang Sultan Ismail Petra\n\nto\n\tLapangan Terbang Antarabangsa Senai"); } } int passanger(y) { int x; float price=1; float total_price1,total_price2,total_price3,total_price4; int type,person; do { printf("\ttype of passangers\n\t1-old folks\n\t2-adult\n\t3-children\n"); printf("sila pilih cik..hehehe\n"); scanf("%d",&type); system("cls"); while(type<1||type>3) { printf("invalid type..choose again\n"); printf("\ttype of passangers\n\t1-old folks\n\t2-adult\n\t3-children\n"); printf("sila pilih cik..hehehe\n"); scanf("%d",&type); system("cls"); } printf("number of person\n"); scanf("%d",&person); system("cls"); while(person<0) { printf("please enter positive number\n"); printf("number of person\n"); scanf("%d",&person); system("cls"); } if(type==1) total_price1+=(price*0.3*person); else if(type==2) total_price2+=(price*0.1*person); else if(type==3) total_price3+=(price*1*person); total_price4=total_price1+total_price2+total_price3; printf("1-add passanger\n2-proceed\n"); scanf("%d",&x); system("cls"); }while(x==1); printf("total price is RM%.2f\n",total_price4); } void intro(x) { printf ("\t\t\t\t----------------------------\n"); printf ("\a\t\t\t\tWelcome to Hornbill Airlines\n"); printf ("\t\t\t\t----------------------------\n"); printf ("\n\t\t\t\tEnsuring Your Priority First\n"); }
why i cant display the correct price??
Are you aware of your compilation errors?
theres no error when compilation
Well this is what I got when I tried, prog.cpp: In function ‘int main()’: prog.cpp:17: error: ‘system’ was not declared in this scope prog.cpp:37: warning: format ‘%s’ expects type ‘char*’, but argument 2 has type ‘char (*)[10]’ prog.cpp:62: warning: format ‘%s’ expects type ‘char*’, but argument 2 has type ‘char (*)[10]’ prog.cpp:66: warning: format ‘%s’ expects type ‘char*’, but argument 2 has type ‘char (*)[10]’ prog.cpp:3: error: too many arguments to function ‘int passanger()’ prog.cpp:107: error: at this point in file prog.cpp:104: warning: unused variable ‘price’ prog.cpp:10: warning: unused variable ‘price’ prog.cpp:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp:41: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp:45: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp:49: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp:57: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp:62: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp:66: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp:70: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp:93: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp:95: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp:99: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result prog.cpp: At global scope: prog.cpp:223: error: ‘int passanger’ redeclared as different kind of symbol prog.cpp:3: error: previous declaration of ‘int passanger()’ prog.cpp:223: error: ‘y’ was not declared in this scope
what is this visual basic?
C++
i'm using c not c+++
you declared int passanger(); but you defined int passanger(y) They are inconsistent, and the version with the y doesn't give y's type (e. g. int) They should both be e. g. int passanger(int y) also, passenger is spelled with an e (but the compiler doesn't care)
in addition, you're using some function "system" which you haven't declared. The rest are just warnings.
Join our real-time social learning platform and learn together with your friends!