can anyone help me to detect error if the programme of hotel managemaent

Discussion in 'C' started by max pro, Aug 24, 2012.

  1. max pro

    max pro New Member

    Joined:
    Aug 15, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    #include<stdio.h>
    #include<string.h>
    #include<stdlib.h>
    void checkin();
    void checkout();
    void records();
    void calc();
    struct customer
    {
     int room_id;
     char f_name[20];
     char l_name[20];
     char nationality[20];
     int advance;
     struct list *next;
    
    };struct customer new1[100];
     *start;
    
    struct date
    {
    int day;
    int month;
    int year;
    };struct date doe[2];
    
      main()
      {
    	int menu;
    	start=NULL;
    
    	{
     printf("1.room details\n2.check In\n3.Check out\n4.Edit\n5.Report\n6.Exit\nEnter your choice");
      scanf("%d",&menu);
      }
    
      if (menu==1)
    
    
    
    void checkin()
    {
    printf("Category:\nSS-&gt;Single Suite:\nSR-&gt;Single Room:\nDS-&gt;Double Suit:\nDR-&gt;Double Room:\n");
    char category[4];
    printf("select the category of room: \n");
    gets(category);
    
    	  puts("Enter the details of the customer:\nRoom alloted...");
    	  gets(new1[i].room_id);
    	  for(i=0;i&lt;=99;i++)
    	  puts("Enter the first name of the customer:");
    	  gets(new1[i].f_name);
    	  for(i=0;i&lt;=99;i++)
    	  puts("Enter the last name of the customer:");
    	  gets(new1[i].l_name);
    	  for(i=0;i&lt;=99;i++)
    	  puts("Enter the nationality of the customer:");
    	  gets(new1[i].nationality);
    	  for(i=0;i&lt;=99;i++)
    	  puts("Enter the date of entry of the customer in the form dd/mm/yyyy:");
    	  scanf("%d%*c%d%*c%d",&doe.day,&doe.month,&doe.year);
    
    		puts("Enter the amount of the advance paid by the customer:");
    	  gets(&new1[i].advance);
    	  for(i=0;i&lt;=99;i++)
    }
     void checkout()
     {
     printf("enter the date of check out in the form dd/mm/yyyy:\n");
     scanf("%d%*c%d%*c%d", &doe.day,&doe.month,&doe.year);
      /*bill calculator*/
    
     void calc();/*function call*/
     }
     void calc()/*function defination*/
    {
    int func1(int x);
    void main()
    {
    
    int day1,mon1,year1,day2,mon2,year2;
    int ref,dd1,dd2,i;
    printf("Enter first day, month, year");
    scanf("%d%d%d",&day1,&mon1,&year1);
    scanf("%d%d%d",&day2,&mon2,&year2);
    ref = year1;
    if(year2&lt;year1)&gt;
    ref = year2;
    dd1=0;
    dd1=func1(mon1);
    for(i=ref;i&lt;year1;i++)&gt;
    {
    	if(i%4==0)
    	dd1+=1;
    }
    dd1=dd1+day1+(year1-ref)*365;
    printf("No. of days of first date fronm the Jan 1 %d= %d",year1,dd1);
    /* Count for additional days due to leap years*/
    dd2=0;
    for(i=ref;i&lt;year2;i++)&gt;
    {
    	if(i%4==0)
    	dd2+=1;
    }
    dd2=func1(mon2)+dd2+day2+((year2-ref)*365);
    printf("No. of days from the reference year's first Jan = %d",dd2);
    printf("Therefore, diff between the two dates is %d",abs(dd2-dd1));
    
    }
    
    
    
    
    int func1(x)       //x for month y for dd
    {  int y=0;
    switch(x)
    {
    case 1: y=0; break;
    case 2: y=31; break;
    case 3: y=59; break;
    case 4: y=90; break;
    case 5: y=120;break;
    case 6: y=151; break;
    case 7: y=181; break;
    case 8: y=212; break;
    case 9: y=243; break;
    case 10:y=273; break;
    case 11:y=304; break;
    case 12:y=334; break;
    default: printf("Error encountered");
    }
    return(y);
    } /*bill opens in a file*/
      {
    FILE *fp;
    char ch;
    fp=fopen("qqq.c","r");
    while(1)
    {
    ch=fgetc(fp);
    if(ch==EOF)
    break;
    printf("%c",ch);
    }
    printf("\n");
    fclose(fp);
    return 0;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    printf("enter the room id which is to be emptied:");
    free(void,**************)
    
     }
    void records()
    printf("1.Show room records\n");
    printf("2.show customer records\n");
    scanf("%d",)
    }
     
  2. hobbyist

    hobbyist New Member

    Joined:
    Jan 7, 2012
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    0
    In standard C, you need to declare variables at the start of a code block.

    Code:
    puts("...");
    char item[4];
    
    stuff like that won't compile in standard C; however, I believe it will if compiled as cpp.

    Code:
    struct customer
    {
    int room_id;
    char f_name[20];
    char l_name[20];
    char nationality[20];
    int advance;
    struct list *next;
    
    };struct customer new1[100];
    *start;
    struct customer *next; is *probably* what you're after

    if you use code tags and formatted source, it will be easier to see what other things may be problematic.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice