Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Not assignment request..having good algorithms

Reply
Thread Tools

Not assignment request..having good algorithms

 
 
happy
Guest
Posts: n/a
 
      01-14-2005
That request of having sorting program for such setup programs was not
a request to an assignment but to have good ideas about sorting program
..
#include <stdio.h>
#include <conio.h>
struct customer_record /*Defining a csutomer record*/
{
int customer_no;
int no_of_weeks;
char tv_type;
};


main ()
{
/*-------1-open file for output*/
struct customer_record customer;
FILE *fp_setup;
if ((fp_setup=fopen("setup.txt","w")) == NULL)
{
printf("\nCan not open file 'setup.txt' for writing \n");
printf("Program is termainted");
exit();

}


clrscr();

/*-------2-while more customers----------separate function-------*/
do {
/*-------2-1-input customers record------separate function-------*/
customer_input(&customer);
/*-------2-2-write customer record to file*/
fprintf(fp_setup,"%4d%2d%c\n",customer);


} while (another_customer()=='y');


/*-------3-write end of file record to file */
fprintf(fp_setup,"%4d%2d%c\n",9999,99,' ');
/*-------4-close file*/
fclose(fp_setup);
return 0;


}


customer_input(cust)
/*---------------------*/
struct customer_record *cust;
{
printf("\nEnter customer number :");
scanf("%4d",&(*cust).customer_no);
printf("\nEnter number of weeks rent due :");
scanf("%2d",&(*cust).no_of_weeks);
printf("Enter type of rental -c for colors TV");
printf("\n -b for black and white TV");
printf("\n -v for video");
printf("\n -o for other : ");
scanf("\n");
scanf("%c",&(*cust).tv_type);


}


another_customer()
/*----------------*/
{
char another;
printf("\nAnother new_screen_customer for input (y or n) : ");
scanf("\n");
scanf("%c",&another);
return (another);


}

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A good c/c++ algorithms / design patterns book CellDivider C++ 11 05-28-2007 08:13 PM
good algorithms come with practice and reading good code/books? vlsidesign C Programming 26 01-02-2007 09:50 AM
Assignment operator self-assignment check Chris C++ 34 09-26-2006 04:26 AM
Augument assignment versus regular assignment nagy Python 36 07-20-2006 07:24 PM
Not assignment rquest..having doof algorithms happy C Programming 0 01-14-2005 01:55 AM



Advertisments