473,410 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

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....?

------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #define MAX 10
  5.  
  6. int i, agedata, Num, x, y;
  7. char telnodata[11], namedata[20];
  8.  
  9. struct callersinfo
  10. {
  11.     char callername[20];
  12.     char telno[11];
  13.     int age;
  14. };
  15.  
  16. typedef callersinfo callperson;
  17. callperson caller[10];
  18.  
  19. int main()
  20. {
  21.     printf("\nFIRE BRIGADE DEPARTMENT");
  22.  
  23.     for(i=0;i<MAX;i++)
  24.         {
  25.             Num=Num++;
  26.             printf("\n\nName: ");
  27.             scanf("%s",&namedata);
  28.             printf("Tel. No: ");
  29.             scanf("%d",&telnodata);
  30.             printf("Age: ");
  31.             scanf("%d",&agedata);
  32.     if (agedata<10)
  33.         {
  34.             printf("Type of call: 2");
  35.             printf("\nTHE CALL MAY BE FAKE. BE CAUTIOUS!\n");
  36.         }
  37.     else 
  38.         if (agedata>=10)
  39.         {
  40.             printf("Type of call: 1");
  41.             printf("\nTHE CALL IS A GENUINE EMERGENCY CALL\n");
  42.         }
  43.  
  44.             strcpy (caller[i].callername,namedata);
  45.             strcpy (caller[i].telno,telnodata);
  46.             caller[i].age=agedata;
  47.         }
  48.  
  49.     for(i=0;i<MAX;i++)
  50.         {
  51.             printf("\nName: %s",caller[i].callername);
  52.             printf("\nTel. No: %s",caller[i].telno);
  53.             printf("\nAge: %d",caller[i].age);
  54.  
  55.     if (caller[i].age<10)
  56.         {
  57.             printf("\nType of call: 2");
  58.             printf("\nTHE CALL MAY BE FAKE. BE CAUTIOUS!\n");
  59.             x=x++;
  60.         }
  61.  
  62.     else
  63.         if (caller[i].age>=10)
  64.         {
  65.             printf("\nType of call: 1");
  66.             printf("\nTHE CALL IS A GENUINE EMERGENCY CALL\n");
  67.             y=y++;
  68.         }
  69.         }
  70.  
  71.     printf("\nSummary:");
  72.     printf("\nTotal number of callers: %d",Num);
  73.     printf("\nNumber of genuine emergency calls: %d",y);
  74.     printf("\nNumber of fake calls: %d",x);
  75.     return 0;
  76. }
Oct 16 '12 #1
2 1587
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

You haven't told us what's wrong.
Oct 16 '12 #2
Hello ,
In your program just slightly modify the following code as:
typedef struct callersinfo callperson;
Oct 16 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John Smith | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <body> <div id="navcontainer"> <ul...
11
by: howa | last post by:
#include<iostream> using namespace std; int main(int argc, char* argv) { cout<<sizeof(argv) / sizeof(argv) ; return 0; };
1
by: samra | last post by:
#include <iostream.h> #include <stdlib.h> class Purchased_item { private: static int itemno; int price; int quantity; ...
2
by: atlkhan | last post by:
Can someone please explain this php code. I would be grateful <?php // --------------- file tape2matlab2php.php // NOTE: if web-server and matlab server are NOT located on the same mashine...
1
by: Rocky86 | last post by:
Hi ppl anyone care to explain to me what is the following PHP code doing? $uname=$_GET; if($uname=="all") { $fetched=mysql_query("SELECT * FROM location"); while($row =...
33
by: Rocky86 | last post by:
Hello can somebody explain the code to me thx in advance!! <?php $temp=""; $sqlconnect=mysql_connect("localhost","hyperian_track","__munged__"); if(!$sqlconnect) die(mysql_error()); ...
8
by: Matt | last post by:
Hello. I'm struggling to work out what bit of matrix manipulation the following piece of code is doing to the 3x3 matrix given: #include <stdio.h> int main() { int check_mat = { { 1 , 2...
7
by: AAaron123 | last post by:
I read the help on which says: The ClientScriptManager class is used to manage client-side scripts and add them to Web applications... But could use a little help. Can someone tell me what...
2
by: sailormoon | last post by:
this information i put in data.txt 11221 MOHD IRFAN 80 70 11222 NURUL FITRAH 80 90 11223 MOHD FARHAN 70 80 11224 WAFFIN WARDAH 80 60 11225 SYAMSUL 50 50 99999 TAMAT 0 0 #include<fstream.h>
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.