PDF- c programming examples pdf,easy -Introduction to C Programming - C Programming

signment for 1st Year 1st Semester of APIIT



INCOURSE ASSIGNMENT Problem Solving and Program Design Using C Prepared By A

Ahamed Nishadh (CB004081) S

Ilangakoon (CB004041) A

Tiffaniya Fernando (CB004165) Module Code & Title AAPP005-3-2 – PSPD Cohort DF10A1ICT Date of Submission 25th January 2011 Instructor Mr

Thangavel Saravanan

Submitted in partial fulfillment for the degree of Bachelor of Science (Hons) in Computing


We understand what is meant by plagiarism

The implications of plagiarism have been explained to us by our lecturer

This project is all our work and I have acknowledged any use of the published or unpublished works of other people

Group Leader’s Signature :

Date : 25th January 2011

Total number of pages : 49 pages

Class Code : DF10A1ICT

Submission Date :

Students Names

Leader :

Due Date :

Ahamed Nishadh (CB004081)

Members : S

Ilangakoon (CB004041) A

Tiffaniya Fernando (CB004165)

49 pages

Total Number of Pages :

ACKNOWLEDGEMENTS Firstly we would like to thank our lecturer Mr

Thangavel Saravanan for all the help and guidance given to us while doing this assignment

Especially for teaching us this module in such a way that we were able to learn this highly technical module very easily

Also there are many individuals who have helped us in numerous ways directly and indirectly so that we were able to complete this assignment

APIIT Lanka for providing us with resources and the Tech Team at APIIT Lanka for their assistance at required times

And last but not least our friends,

parents and the well-wishers without whose moral support and encouragement,

we would not have been able to do a good job


if there are any shortcomings in this project,

then we request to excuse us for all those and accept this documentation

Ahamed Nishadh Deshan Ilangakoon Tiffaniya Fernando


1 – IF,

ELSE Conditions


This system will be only used by the shop’s assistant who will enter the order as the customer provides the requirements

The system will take the order

do all necessary calculations and printing the receipts

The guide lines that we will use when doing the development of the project will be according to the objectives,

given below that we hope to achieve by the end of the development

Make a faster and more reliable point of sale system for the Sandwich Bar

Generate accurate and up to date reports for management on the performance of the shop

Maintain all transaction details and store this information in a separate file

Make the system easy and simple for the user to operate

The project should be completed with the allocated time frame for it

The project should meet all the above mentioned objectives

Should not be a burden,

In the case where the project encounters problems and Code needs to be changed the company will need someone with professional knowledge in C Programing language for assistance

The system will need a C compiler to operate and this software does not come pre-installed in most computers

The system operational flow is fairly straight forward and easy to follow

For the effective running of this system we have used several functions,

The system uses all these features to help in running smoothly

The system starts off by showing the main menu

At this point the system requires an input from the user as to whether he wishes to make a New Order,

Check Available Sandwiches or whether he wishes to quit

To do this the user will have to enter 1,

Here we have used a Switch that will read the information that is entered and will them according to the information that is given the Switch will call a function to carry out the operation that the user has selected

If the user selects 1 the system will then take the user to the New Order section of the system

Here the user is presented with 4 choices

The first three relate to which type of filling that the customer wishes to have

The fourth is to cancel the order and go back to the main menu

In the event that the user wishes to make a new order he will have to simply enter 1,

Seafood and Vegetarian respectively and the system will store the information and move in to the “breadf” function

Here the system goes into the “breadf” Function where the user will have to enter what sort of bread the customer wishes to have

The three options are 1-Baguette,

From here the system will move to the next segment of the new Order process where the customer has to enter the size of the sandwich he wishes to eat

This is done in the “sizef” Function

The user has to select from three sizes Large,

Medium and Small

The system will then take the user to the next process which is the “topf” Function

Here the user must enter the toping that he wishes to have on the sandwich

He is provided with three options 1-Cheese,

The user can have either one,

two or all three of the toppings

He can also opt not to have any of the available toppings

This process works by having a While loop and a Do While loop that will run three times asking the user to enter a topping or until the user opts to exit the topping option by selecting ‘0’ that will jump the system out of the loop

After the user has given the specifications for his sandwich the user will then be asked how many sandwiches he wishes to have of the particular type that he has selected

For this the function “qytf” will be called up

Here when the user enters the choice the system will run a check to see if there is sufficient filling to satisfy the customer’s requirement

If there is not the system will prompt an error saying that there is insufficient filling to meet the order requirement for that particular type of filling

Here the user will have to re-enter a quantity that meets the available amount present in the system

If there is sufficient amount of filling to meet the customer’s order then the system moves on to the next function is the the “invoice” Function

Here the user is presented with a screen showing his order and will request the user to select whether the order displayed is in fact correct

If it is not the user must enter ‘n’ and the system will then return back to the main menu and the user can start the process again

If the order is correct the user will have to enter ‘y’ and the system will take the user to the next stage of the process

When the user has confirmed that the order is in fact what was requested then the system will ask the user what the method of payment will be

Here there are two options available for the user

One the user can select to make the payment by Cash

If the user selects this option then the system will simply display the final bill for the user

If however the user selects to make a payment by credit card then the system will again move to the final bill process but here if the user has made an order that is greater than Rs

Here we have made the assumption that the Sandwich Bar will only accept Visa Credit Card

Once this is done the system will show the bill containing the individual price per sandwich,

the relevant discount that takes into effect and the Grand Total

After this the user can return to the main menu to either make a new order or to select one the two remaining options

The next option that the user is presented with when the system is at the main menu is the option to check how many more sandwiches can be made

This runs through the “availability” Function

If the user selects this option the system will move into the next segment where the system prompts the user to enter the type of bread that the user wishes to search for

When the user does this the system will display how many more sandwiches of the particular bread type can be made

After this the system will move back to the main menu

The user if he has finished all the work that he has to do with the system may opt to shut the system down

To do this the user simply has to go to the main menu and select the Exit option

This will then shut the program down

//GLOBAL VARIABLES int count=0

//STRUCTURE VARIABLES struct order bill[15]

//DECLARING FUNCTIONS void neworder()


SANDWICH BAR\n ===================\n\n")

printf(" WHAT DO YOU WANT TO DO :\n 1

New Order\n 2

Check Available Sandwiches\n\n 3

Exit\n\n\n Choice is : ")

switch(mainmenu) { case 1: { neworder()

} default: { printf("\n INVALID CHOICE


//"NEW ORDER" FUNCTION STARTS HERE void neworder() { int filling

SANDWICH BAR\n ===================\n\n")

printf(" Enter the Type of Filling Required\n 1

Chicken\n 2

Seafood\n 3

Vegetarian\n\n 4

CANCEL ORDER\n\n Choice is : ")

switch(filling) { case 1: { if(ccountcrem) { printf("REQUESTED AMOUNT NOT AVAILABLE\n")


printf("\nEnter Quantity Again")

//"INVOICE" FUNCTION STARTS HERE void invoice() { int confirm

SANDWICH BAR\n ===================\n\n")

printf(" Filling : %c\n",bill[count]

printf(" Bread : %c\n",bill[count]

printf(" Size : %c\n",bill[count]

printf(" Total Number of Sandwitches Required : %d\n",bill[count]

printf("\n\n CONFIRM ORDER (1:Yes/2:No) : ")

switch(confirm) { case 1:{ paymentf()

filling=='C') { ccount=ccount+bill[count]

filling=='S') { scount=ccount+bill[count]

filling=='V') { vcount=ccount+bill[count]

printf("Press 'ENTER' to Close the Bill")

} default:{ printf("\n INVALID CHOICE


} } }while(confirm>0 || confirm1000) { bill[count]