What could be wrong in this program code? Help me...!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sharon92
    New Member
    • Oct 2012
    • 1

    What could be wrong in this program code? Help me...!

    Hi all,

    I am beginner in C. I tried to write a code using struct and typedef [as written below] but I can't get the result as I wanted to. Is there anybody out there can help and show me why I failed to run my program....?

    ------------------------------------------------------------
    Code:
    #include <stdio.h>
    #include <string.h>
    
    #define MAX 10
    
    int i, agedata, Num, x, y;
    char telnodata[11], namedata[20];
    
    struct callersinfo
    {
    	char callername[20];
    	char telno[11];
    	int age;
    };
    
    typedef callersinfo callperson;
    callperson caller[10];
    
    int main()
    {
    	printf("\nFIRE BRIGADE DEPARTMENT");
    	
    	for(i=0;i<MAX;i++)
    		{
    			Num=Num++;
    			printf("\n\nName: ");
    			scanf("%s",&namedata);
    			printf("Tel. No: ");
    			scanf("%d",&telnodata);
    			printf("Age: ");
    			scanf("%d",&agedata);
    	if (agedata<10)
    		{
    			printf("Type of call: 2");
    			printf("\nTHE CALL MAY BE FAKE. BE CAUTIOUS!\n");
    		}
    	else 
    		if (agedata>=10)
    		{
    			printf("Type of call: 1");
    			printf("\nTHE CALL IS A GENUINE EMERGENCY CALL\n");
    		}
    
    			strcpy (caller[i].callername,namedata);
    			strcpy (caller[i].telno,telnodata);
    			caller[i].age=agedata;
    		}
    	
    	for(i=0;i<MAX;i++)
    		{
    			printf("\nName: %s",caller[i].callername);
    			printf("\nTel. No: %s",caller[i].telno);
    			printf("\nAge: %d",caller[i].age);
    			
    	if (caller[i].age<10)
    		{
    			printf("\nType of call: 2");
    			printf("\nTHE CALL MAY BE FAKE. BE CAUTIOUS!\n");
    			x=x++;
    		}
    				
    	else
    		if (caller[i].age>=10)
    		{
    			printf("\nType of call: 1");
    			printf("\nTHE CALL IS A GENUINE EMERGENCY CALL\n");
    			y=y++;
    		}
    		}
    
    	printf("\nSummary:");
    	printf("\nTotal number of callers: %d",Num);
    	printf("\nNumber of genuine emergency calls: %d",y);
    	printf("\nNumber of fake calls: %d",x);
    	return 0;
    }
    Last edited by Rabbit; Oct 16 '12, 05:05 AM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code.

    You haven't told us what's wrong.

    Comment

    • Shubhangi24
      New Member
      • Oct 2012
      • 20

      #3
      Hello ,
      In your program just slightly modify the following code as:
      typedef struct callersinfo callperson;

      Comment

      Working...