c programming for a beginner

By dj_ineedmoney ·
the peolples details to be used

324 herold st, here, VIC 3180
John, William

123 Smith St, DOncaster, NSW 28**
John, william

121 Martin Place, Point Cook, VIC 2**0
Brian, Davis

12 Peterson St. Fadden, ACT 2904
Peter, Smith


The work

Task 1 [10 marks code correctness]

The program should be menu driven. The user should be presented with the following menu:

1. Load catalogue from file
2. Delete property from catalogue
3. Save catalogue to file
4. Search property
5. Sort and display catalogue
6. Quit

After selecting one of the above options the corresponding task should be performed. After completing the selected task, the menu should be displayed again for the user to choose from again.

Task 2 [20 marks code correctness]

Implement the load catalogue from file menu option. After selecting this option the user should be asked to enter the name of a file to be loaded. The file should then be loaded into a run-time(dynamically) allocated data structure. You should not use compile-time (static) memory allocation. You can assume the file will have the following format.

[Number of properties]
[Address of property]
[Real estate agent firstname], [Real estate agent surname]
[Number of bedrooms]
[Price of property]

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

what is your point or question?

by Dr Dij In reply to c programming for a begin ...

that's a nice example of an assignment, so what? what is your point in posting this?

are you sharing that to show us what is happening in your C class?
are you trying to get someone to do your homework for you?
are you trying to start a discussion if it is too hard or easy?

Collapse -

My vote is with homework...

by boxfiddler Moderator In reply to what is your point or que ...

lots of that seems to show up around here periodically.

Collapse -

Start here.

by Bizzo In reply to c programming for a begin ...

/* hello world program */
#include "stdio.h"

void main()
printf("\nHello World\n"); // print to screen

And then learn C.

A quote from your rather lengthy post:
"To get full marks for this task you should design your sorting algorithm ..."

The word here is YOU. *YOU* should design.

Rather than post the entire assignment, you're only goning to get flamed with this, try working on the assignment yourself. If you get stuck, post a question. You might be surprised, you might actually manage to do the work yourself. Unless you're some sort of waster who expects everyone to drop everything to help you. You only get from life what you put in.


Collapse -

Here is a little bit for you to chew on..

The term associated with extension methods is duct typing.

Listing 1 shows an extension method that uses Reflection to send the property values of an object to a TextWriter stream. In SimpleExtensionMethod an array of integers is assigned to the anonymous variable numbers. A LINQ query is invoked to create a new anonymous type from the number indicating the value and the number?s parity?odd or even. Finally the result of the query calls the extension method Write, sending the property name and value for each object to the console.

Listing 1: An extension method that displays the state of an object using new features of .NET and Reflection.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using System.Data;
using System.Data.SqlClient;
namespace ExtensionMethod
class Program
static void Main(string[] args)
public static void SimpleExtensionMethod()
var numbers = new int[]{1,2,3,4,5,6};
var oddsEvens = from num in numbers
let parity = num % 2 == 0 ? "Even" : "Odd"
select new {Number=num, Parity=parity};
foreach(var obj in oddsEvens)
public static class WriteObjectState
// extension method that writes an object's state
public static void Write(this object obj, TextWriter writer)
var formatted = from info in obj.GetType().GetProperties()
let value = info.GetValue(obj, null)
select new {Name=info.Name, Value=value==null?"":value};
Array.ForEach(formatted.ToArray(), r=>

The extension method Write in the static class WriteObjectState extends object and accepts a TexTWriter, for example, Console.Out. The Write extension method uses a LINQ query to select and iterate through all of the object?s properties and project these aspects of a property to a new type. The Array.ForEach method iterates over each property name and value pairing and sends these to the writer (the console).

Please post back if you have any more problems or questions.

Related Discussions

Related Forums