You are on page 1of 49

# Software for Engineers CE00554-1

Individual Assignment

Page 1 of 49

S.No 1. 1.1. 1.2 1.3 1.4 2. 2.1 2.2 2.3 2.4 2.5 2.6 2.7 3 4
5

Topic Section A Introduction of maple Solution of question 1 Solution of question 2 Solution of question 3 Section B Introduction of c Objective Project description C programming concepts User guide Limitation Future enhancement Conclusion References Appendix

36-49

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 2 of 49

Maple
Maple Software is a software development company that has been providing software services and other IT enabled services for over eight years to independent software vendors and companies reliant upon technology. Maple provides Software development, testing, staffing and IT enabled services to improve our clients' performance in healthcare, judiciary, public safety and retail organizations throughout North America, Europe and Asia. In 1980 Prof. Keith Geddes and Gaston Gonnot started development of Maple at the University of Waterloo, Ontario, Canada. The objective was to construct a mathematical software system to be used both in research and education. The very first - but quite limited - version of Maple has been completed after just three weeks time. MAPLE is a powerful mathematical software package. It can be used to obtain both symbolic and numerical solutions of problems in arithmetic, algebra, and calculus and to generate plots of the solutions it generates. This is the first of a set of tutorials that outline how to use MAPLE. In it, we outline basic MAPLE syntax and show how to solve sets of algebraic equations, generate data plots, and generate an annotated printout of the results. Realize, however, that we are barely tapping the power of this tool to perform almost any type of mathematical analysis you might ever need to perform. Once you have mastered the material in this tutorial, you may go on to the second one, which covers differentiation, integration, and solving ordinary differential equations.

OBJECTIVE
The objective of Section A of assignment is to test the knowledge and understanding of the students about the MAPLE.

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 3 of 49

Question 1 >

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 4 of 49

as V1 as first vector in the form as shown tj t 3k Here we write the given vector u 5t 2i below and press the enter >

cos tj as V2 as second vector in the form as shown Here we write the given vector v sin ti below and press the enter

>

Write the dot product V1 and V2 as shown below and press the enter the result of dot product will be seen automatically > Hence the result of the dot product of the given vector will be 5t 2 sin(t ) t cos(t) . Write the cross product V1 and V2 as shown below and press the enter the result of cross product will be seen automatically >

Hence result of cross product of vector will be t 2 cos(t ) i t 2 sin(t) j (5t 2 cos(t) - tsin(t) k . Write the vector angle V1 and V2 as shown below and press the enter the result of angle will be seen automatically >

## Hence the angle between the given vectors will be (

4

5t 2 sin(t ) t cos(t) 26 t t
2

sin(t ) cos(t )
2

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 5 of 49

Solution of question 2
First of all we write with (student); and press the enter then result will be shown on the display like this >

Write the question given in the question and press the enter the entering of question will be done > Write sol: =Simpson (f(x),x=1..5,4); and press the enter the equation of Simpson rule will be displayed will be like this >

Again, write evalf(sol); and press the enter the result will be seen like this >

Hence the result of the question by Simpson rule will be 5.73. Write sol2: =trapezoid (f(x),x=1..5,4); and press the enter the equation of trapezoid rule will be displayed will be like this >

Again, write evalf(sol2); and press the enter the result will be seen like this >

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 6 of 49

Solution of question 3
First of all we write with (stat, describe); and press the enter then result describe will be shown on the display > Write again with (describe); and press the enter the result will be seen like this >

Write data and enter the data given in the question > Write mean (data) and press enter the result of mean will be seen automatically >

17 4.25 . 4 Write variance (data) and press enter the result of variance will be seen automatically

>

## Hence the result of the given data is

63 3.93 . 16

Write standard deviation (data) and press enter the result of variance will be seen automatically >

3 7 1.98 . 4

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 7 of 49

## SECTION B C programming language: - A high-level programming language developed by Dennis

Ritchie at Bell Labs in the mid 1970s. Although originally designed as a systems programming language, C has proved to be a powerful and flexible language that can be used for a variety of applications, from business programs to engineering. Along with implementing system software, it is also widely used for developing portable application software. C is one of the most programming languages and there are very few computer architectures for which C compiler does not exist. C is a particularly popular language for personal computer programmers because it is relatively small - it requires less memory than other languages. . It is a small language, with just 32 keywords. It provides high-level structured programming constructs such as statement grouping, decision making, and looping, as well as low level capabilities such as the ability to manipulate bytes and addresses. The first major program written in C was the UNIX operating system, and for many years C was considered to be inextricably linked with UNIX. Now, however, C is an important language independent of UNIX. C is a general-purpose programming language, and is used for writing programs in many different domains, such as operating systems, numerical computing, graphical applications, etc

OBJECTIVE
A Shopping Mall manages its sales and purchase of some products with the help of shopping Mall Management System (SMMS). Shopping Mall Management System records the weekly sales and purchases of a product. SMMS may be used to one or more of the following information:

Value of weekly sales and purchases Total value of all the products purchased Total value of all the products sold Total value of each product purchased and sold

The products purchased and sold can be represented by two-dimensional arrays P and S respectively. Then

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 8 of 49

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 9 of 49

## Exit:- This function is use to terminate from the program.

PROJECT DESCRIPTION
Since this is an individual assignment, so before the beginning of my work in C, I have gone through different compilers, with which I can make this work. But the best I've chosen here is Turbo C + + on Windows 7, which runs very smoothly and correctly without hanging out of the system at any time. It has a compiler that runs the program and compiles the program and also takes the errors in the same.

Functions Used while programming:Void main ( ):-Void is a value of a function type that means nothing is returned. Some
languages have special types of functions known as procedures or subroutines that don't return a value The standard committee has also introduced that int main, which means that series of functions pass kind of additional information to the invoked program. However, main is still defined to take two parameters for these functions; the environment information is assigned to an external object extern char environ. The main function of the vacuum is to call other user-defined functions. According to void main, there are four main functions that appear as the user enters the selection. 1. Math operations, 2. Array operations, 3. Matrix operations, 4. Exit

Void math function It is the main function of math menu which shows all the Math Functions. This is a list of operators in the C and C++ programming languages. All the operators listed exist in C++; the fourth column "Included in C", dictates whether an operator is also present in C. Note that C does not support operator overloading. In this, the user will have to enter the choice according to their wish and then the results will be displayed in the screen according to the users choice. Function pointers allow you to pass functions as parameters to another function. This enables you to give the latter function a choice of functions to call. The main menu of Math functions are as follows: 1. Quadratic Equation 2. Leap Year or Not 3. Prime Number or not 4. Addition of two addresses.
Level 1 Asia Pacific Institute of Information Technology 2014

## Software for Engineers CE00554-1

Individual Assignment

Page 10 of 49

5. Multiplying two addresses. 6. Division of two addresses. 7. Modulo operation on pointer. 8. Cannot perform bitwise AND, OR, XOR operations on pointer. 9. Cannot perform NOT operation or negation operation. 10. Exit Void array operation ():- It is the main function of array menu which shows all the Array Functions. A static array with a dimension of 0 is allowed, but no space is allocated for it. It's useful as the last member of a variable length struct, or as the degenerate case of a template expansion.. It is the function which helps to calculate the sort the array in the ascending order, find the mean of the array elements and find the standard deviation of the array elements. When the user will enter the size of the array of his choice, and then once again it will be asked from the user, please enter the elements of that size. These are analogous to C arrays. Static arrays are distinguished by having a length fixed at compile time. Void matrix operation ( ):- Matrices should be stored in row-major arrays, which is fairly standard. The user must keep track of array dimensions and send them to the functions; mistakes on dimensions will not be caught by the library. It is the function which helps to calculate the addition of two matrices, subtraction of two matrices, multiplication of two matrices and Norm of a Matrix. Matrix multiplication in c language: c program to multiply matrices (two dimensional array), this program multiplies two matrices which will be entered by the user. Firstly user will enter the order of a matrix. The main menus of matrix functions are as follows:

C PROGRAMMING CONCEPTS
#include<stdio.h>:#include <stdio.h> instructs the preprocessor to include the contents of the standard input / output header file, (stdio.h) in the program, in order to use certain functions such as printf and scanf. The directive #include tells the preprocessor portion of the C to attach the stdio.h file to the file with the source code. Because the line of code, #include causes the preprocessor to act, it is called a preprocessor directive.
Level 1 Asia Pacific Institute of Information Technology 2014

## Software for Engineers CE00554-1

Individual Assignment

Page 11 of 49

#include<conio.h>:It is a header file which provides the declarations for console and input/output functions conio.h header used in c programming contains functions for console input/output. Some of the most commonly used functions of conio.h are clrscr, getche etc. Functions of conio.h can be used to clear screen, change color of text and background, move text, check if a key is pressed or not and many more. It includes files and contains the definitions of certain functions and procedures which can be used by your program.

clrscr();It is a header file which includes standard library definitions. This function performs to clear text mode window. It clears the current text window and places the cursor in the upper lefthand corner. We use these types of header file so that we can make use of clrscr in the program. If we will not use this header file, and then also using clrscr, then the program will show errors and the given program will not compile neither it will execute. e.g.:- #include<stdio.h> #include <conio.h> void main() { int i; clrscr(); for( i = 0; i < 10; i++) printf("clrscr function test\n"); printf("\n\nPress any key to clear screen"); getch(); clrscr(); printf("The screen has been cleared!"); getch(); }

if-else statements:The keyword if tells the compiler that what follows is decision control statement. The block of statements to be executed must be enclosed in opening and closing braces. If only one statement needs to be executed then braces need not be used. The general form of the if-else statement is,
Level 1 Asia Pacific Institute of Information Technology 2014

## Software for Engineers CE00554-1

Individual Assignment

Page 12 of 49

#include<stdio.h> Int main(){ Int num; Printf (Enter a number you want to check.\n); Scanf (%d, &num); If ((num%2)==0) Printf(%d is even,num); Else Printf(%d is odd,num); }

Switch statement:The switch statement in C is very powerful decision making statement. It reduces the complexity of the program. Hence increases the readability of the program. Switch statement accepts single input from the user and based on that input executes a particular block of statements. The general form of the switch statement, Switch ( integer expression) { case 1: statements; break; case 2: statements; . break; case n: statements; break; default: default_statements; break; }

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 13 of 49

while statement:The C while statement creates a structured loop that executes as long as a specified condition is true at the start of each pass through the loop. A loop is a group of instructions that is executed repeatedly while some condition remains true. The general form: while(expression) { Statements; statement2; .. statementn; }

for statement:The for statement lets you repeat a statement or compound statement a specified number of times. The body of a for statement is executed zero or more times until an optional condition becomes false. The general form is: for (initialization expression ; loop condition; update expression) { Statements; }

break statements:The break statements are used to alter the flow of control. The break statement in a while, for, do-while or switch structure causes immediate exit from the structure. Sometimes, it is necessary to exit immediately from a loop as soon as the condition is satisfied. When break statement is used inside a loop, then it can cause to terminate from a loop. The statements after break statement are skipped. Sometimes, it is necessary to exit immediately from a loop as soon as the condition is satisfied. Sample: #include <stdio.h> #include <conio.h> void main()
Level 1 Asia Pacific Institute of Information Technology 2014

## Software for Engineers CE00554-1

Individual Assignment

Page 14 of 49

## { int i; clrscr(); for(i=1; ; i++) { if(i>5) break; printf("%d",i); } getch(); }

Array:Array is a collection of homogenous data stored under unique name. The values in an array are called as 'elements of an array.' An array is a fixed-size collection of consecutive memory locations. Each memory location in an array is accessed by a relative address called an index or a subscript. These elements are accessed by numbers called as 'subscripts or index numbers.' The general form: Data type array name [array size];

Function:The function is a self contained block of statements which performs a coherent task of a same kind. They make the programs more simple and easy to read and manage. C program does not execute the functions directly. It is required to invoke or call that functions. When a function is called in a program then program control goes to the function body. Then, it executes the statements which are involved in a function body. The general form: Void main ( ) { // Function prototype <return type><function name> // Function Call <function name>
Level 1 Asia Pacific Institute of Information Technology 2014

## Software for Engineers CE00554-1

Individual Assignment

Page 15 of 49

## // Function definition <return_type><function_name> { <function_body>; }

Printf: - In this C programming language tutorial we take another look at the printf
function. The printf function is not part of the C language, because there is no input or output defined in C language itself. The printf function is just a useful function from the standard library of functions that are accessible by C programs. The behavior of printf is defined in the ANSI standard. The standard display function, printf, takes a "format string" that allows you to specify lots of information about how a program is formatted.

## #include <stdio.h> Int main() { Double d =1.4; Print f(%f,d);

Scanf: - The scanf function allows you to accept input from standard in, which for us is
generally the keyboard. The scanf function can do a lot of different things, but it is generally unreliable unless used in the simplest ways.A list of formatted specifies is given below

scanf() function is used to read character, string, numeric data from keyboard Consider below example program where user enters a character. This value is assigned to the variable char and then displayed. Then, user enters a string and this value is assigned to the variablestr and then displayed.

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 16 of 49

USER GUIDE
Screen shots with explanation:For go to menu driven program we have to enter the no of item in the shopping mall.

Figure (1) Users have to input the quantity no of product for first week. .

Figure (2) Users have to input the quantity no of product for second week.

Figure (3)

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 17 of 49

## Users have to input the quantity no of product for third week.

Figure (4) Users have to input the quantity no of product for third week.

Figure (5) Users have to input the quantity no of product for all week.

Figure (6)
Level 1 Asia Pacific Institute of Information Technology 2014

## Software for Engineers CE00554-1

Individual Assignment

Page 18 of 49

Sample output This is the weekly sale matrix of the input the quantity no.

Figure (7) Users have to input the record of weekly purchase items for first week. Enter the quantity of item number for 1 and 2 items.

Figure (8) Users have to input the record of weekly purchase items for second week. Enter the quantity of item number for 1 and 2 items.

Figure (9) Users have to input the record of weekly purchase items for third week. Enter the quantity of item number for 1 and 2 items.

Figure (10)
Level 1 Asia Pacific Institute of Information Technology 2014

## Software for Engineers CE00554-1

Individual Assignment

Page 19 of 49

Users have to input the record of weekly purchase items for first week. Enter the quantity of item number for 1 and 2 items.

Figure (11) Users have to input the record of weekly purchase items for all week. Enter the quantity of item number for 1 and 2 items.

Figure (12)

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 20 of 49

Sample output This is the weekly purchased matrix of the input the quantity number.

Figure (13) Users have to enter the cost price of all item. After enter the cost value, users have enter the selling price of the all item.

Figure (14)

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 21 of 49

After give the all input value of sale price and cost price, the main driven program will be displayed on the screen

Figure (15) The user chooses option first and presses 1. Define the week number and product number. The no of product no 1 in the first week is 2. Now user press y for come to the menu and press enter.

Figure (16)

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 22 of 49

The main driven program will be displayed on the screen. User chooses the option 2 for go through the weekly purchase of any product.

Figure (17) The user chooses option first and presses 2. Define the week number and product number. The no of product no 2 in the second week is 3. Now user press y for come to the menu and press enter.

Figure (18)

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 23 of 49

The main driven program will be displayed on the screen. User chooses the option 3 for go through the monthly sale of any product.

Figure (19) The user chooses option first and presses 3. Define the week number and product number. The no on sale product no 2 in the month is 8. Now user press y for come to the menu and press enter.

Figure (20)

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 24 of 49

The main driven program will be displayed on the screen. User chooses the option 4 for go through the monthly purchase of any product.

Figure (21) The user chooses option first and presses 4. Define the week number and product number. The no on purchase product no 2 in the month is 12. Now user press y for come to the menu and press enter.

Figure (22)

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 25 of 49

The main driven program will be displayed on the screen. User chooses the option 5 for go through the cost price of any product.

Figure (23) The user chooses option first and presses 5. Define the week number and product number. The no on purchase product no 2 in the month is 4. Now user press y for come to the menu and press enter.

Figure (24)

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 26 of 49

The main driven program will be displayed on the screen. User chooses the option 6 for go through the selling price of any product.

Figure (24) The user chooses option first and presses 6. Define the week number and product number. The no sale price of product no 2 in the month is 6. Now user press y for come to the menu and press enter.

Figure (25)
Level 1 Asia Pacific Institute of Information Technology 2014

## Software for Engineers CE00554-1

Individual Assignment

Page 27 of 49

The main driven program will be displayed on the screen. User chooses the option 7 for go through the weekly sale of any product.

Figure (26) The user chooses option first and presses 7. Define the week number and product number. The no sale price of product no 2 in the week is 4. Now user press y for come to the menu and press enter.

Figure (27)

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 28 of 49

The main driven program will be displayed on the screen. User chooses the option 8 for go through the weekly purchase of any product.

Figure (28) The user chooses option first and presses 8. Define the week number and product number. The no on purchase product no 2 in the month is 6. Now user press y for come to the menu and press enter.

Figure (29)

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 29 of 49

The main driven program will be displayed on the screen. User chooses the option 9 for go through the monthly sale of any product. The month sale of all products is 16.

Figure (30) The main driven program will be displayed on the screen. User chooses the option 10 for go through the monthly purchase of any product. The month purchase of all products is 24.

Figure (31)
Level 1 Asia Pacific Institute of Information Technology 2014

## Software for Engineers CE00554-1

Individual Assignment

Page 30 of 49

The main driven program will be displayed on the screen. User chooses the option 11for go through the cost price of all product. The coast price of all products is 4.

Figure (32) The main driven program will be displayed on the screen. User chooses the option 12 for go through the selling price of all product. The sale price of all products is 12.

Figure (33)

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 31 of 49

The main driven program will be displayed on the screen. User chooses the option 13 for go through the total value of weekly purchase of all product. The total value of weekly purchase of all products is 24.

Figure (34) The main driven program will be displayed on the screen. User chooses the option 14 for go through the total value of monthly purchase of all product. The total value of monthly purchase of all products is 96.

Figure (35)
Level 1 Asia Pacific Institute of Information Technology 2014

## Software for Engineers CE00554-1

Individual Assignment

Page 32 of 49

The main driven program will be displayed on the screen. User chooses the option 15 for go through the stock of any product in the mall. The stock of any product of all products is 4.

Figure (36) The main driven program will be displayed on the screen. User chooses the option 16 for go through exit.

Figure (37)

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 33 of 49

LIMITATION OF C LANGUAGE C is case sensitive. We never use the reverse words as variables names. C is a waste language till date many programming languages have came but C still stood stand alone and its great to see its power. As such there is no limitation of C, only a slight. The program and the required conditions have been developed keeping in mind the logical operation. Development program is also used to explain the many limitations and disadvantages that are not necessary at this point to me. Future improvements in a more user friendly and easier to complete with the current program can be easily. 1. Turbo C compiler just permits us to access 1 MB Memory. 2. ODBC Programming is not possible in Turbo C 3. Turbo C supports only 512 bytes buffer size 4. Heap segment size is just 64 KB in Turbo C 5. Every memory cell has a 20 bits physical address , but due to register size used by Turbo C is 16 bits , So memory models only control the pointers in Turbo C 6. Stack + Heap , Both shares same segments memory in Turbo C 7. Turbo C doesnt support dynamic and dynamic loaded library 8. Multiple process and threads program are not possible in Turbo C 9. System Call implementations are not in Turbo C 10. Memory Protection is not there in Turbo C

FUTURE ENHANCEMENT
It may be that the most we can hope for from the language it is for it to not get in the way of our work. There is a certain amount of Essential Complexity in our work. No matter how good or how high-level the language, we as programmers and software engineers will be left with the tasks of figuring out what to say and how to say it. These programs are suitable GUI giving can be more interactive. Content of the program should be very user friendly. Many other facilities, as well as mathematics, oh, matrix operations, and string functions can be added. This will help you to store user information in the future growth, we are, by file control program can be more moderate. The job of the programming language is to reduce as much Accidental Complexity as possible, leaving us with high Essential Complexity ratio, and keeping this ratio high even as Non Functional Requirements increase.

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 34 of 49

Conclusion: - After completing this assignment the developer has learnt a lot about the C
language and it also helps a lot in enhancing the knowledge in the C language. The development of this C programming has given me some wonderful experiences through which I have learned a lot. From this assignment I got an idea about the function, array and the matrix. I also learnt basic of the C language and the different keywords used in the C language. I also learnt some advance concepts of the C language i.e. array, function and the matrix. I was able to remove all errors from the program and the end result is completely error free. The use of commands such as ELSE, while, do-while, for, etc. have been used where necessary and appropriate validation set that will help you in making the right program.

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 35 of 49

References Brain, M. (2014). HowStuffWorks "The Basics of C Programming". [online] HowStuffWorks. Available at: http://www.howstuffworks.com/c.htm [Accessed 2 Apr. 2014]. Codingunit.com, (2014). C Tutorial printf, Format Specifiers, Format Conversions and Formatted Output | CodingUnit Programming Tutorials. [online] Available at: http://www.codingunit.com/printf-format-specifiers-format-conversions-and-formattedoutput [Accessed 3 Apr. 2014]. Cprogramming.com, (2013). C programming.com - Learn C and C++ Programming Cprogramming.com. [online] Available at: http://www.cprogramming.com/ [Accessed 4 Apr. 2014]. Cs.utah.edu, (2014). C Programming Functions. [online] Available at:

http://www.cs.utah.edu/~germain/PPS/Topics/C_Language/c_functions.html [Accessed 7 Apr. 2014]. fresh2refresh.com, (2012). C printf and scanf with example. [online] Available at: http://fresh2refresh.com/c/c-printf-and-scanf/ [Accessed 11 Apr. 2014]. fresh2refresh.com, (2012). What is C language - C Programming language tutorial. [online] Available at: http://fresh2refresh.com/c/c-language-history/ [Accessed 15 Apr. 2014]. Maplesoft.com, (2014). Maplesoft - Technical Computing Software for Engineers, Mathematicians, Scientists, Instructors and Students. [online] Available at:

http://www.maplesoft.com/ [Accessed 18 Apr. 2014]. Maplesoftllc.com, (2014). Maple Software. [online] Available at:

http://www.maplesoftllc.com/ [Accessed 19 Apr. 2014]. Maple-software.com, (2014). Maple Software Pvt.Ltd.. [online] Available at:

http://www.maple-software.com/ [Accessed 20 Apr. 2014]. Pollock, W. (2014). C Printf and Scanf Reference. [online] Wpollock.com. Available at: http://wpollock.com/CPlus/PrintfRef.htm [Accessed 21 Apr. 2014]. Programming59.blogspot.in, (2014). C and C++ Tutorial: printf() Function in C/c++ Language. [online] Available at: http://programming59.blogspot.in/2011/07/printffunction-in-cc-language.html [Accessed 22 Apr. 2014]. Softonic, (2014). maple 14 software mathematics. [online] Available at:

http://en.softonic.com/s/maple-14-software-mathematics [Accessed 23 Apr. 2014]. Studytonight.com, (2014). User defined Functions in C Language. [online] Available at: http://www.studytonight.com/c/user-defined-functions-in-c.php [Accessed 24 Apr.

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 36 of 49

2014]. Technoexam.com, (2014). Functions in C programming language,Library,User defined functions,Types Available at: of functions,Advantages,program,source code,example. [online]

http://www.technoexam.com/c-language-lecture-study-notes-tutorials-

material/functions-in-c.asp [Accessed 25 Apr. 2014]. Techonthenet.com, (2014). C Language: printf function. [online] Available at:

## http://www.techonthenet.com/c_language/standard_library_functions/stdio_h/printf.php [Accessed 26 Apr. 2014].

APPENDIX
Source code of the whole program:#include<stdio.h> #include<conio.h> void WSOAP(); void WPOAP(); void MSOAP(); void MPOAP(); void CPOAP(); void SPOAP(); void WSAP(); void WPAP(); void MSAP(); void MPAP(); void CPOAP(); void SPAP(); void TVOWPS(); void TVOMPS(); void SOAPAIM(); int s[4][20],p[4][20],cp[1][20],sp[4][20],pd,i,j; void main() { char chrctr; int option;
Level 1 Asia Pacific Institute of Information Technology 2014

## Software for Engineers CE00554-1

Individual Assignment

Page 37 of 49

clrscr();

printf("please input the record of weekly sales items\n"); printf("\nEnter the numbers of items in your shopping mall:> "); fflush(stdin); scanf("%d" ,&pd);

for(i=0;i<4; i++) { printf("\nfor week %d:",i+1); for(j=0; j<pd; j++) { printf("\nEnter the quantity of item number %d :=",j+1); fflush(stdin); scanf("%d",&s[i][j]); } } clrscr(); printf("weekly sales matrix\n"); for(i=0; i<4; i++) { printf("\n"); for(j=0;j<pd; j++) { printf("%d ",s[i][j]); } }

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 38 of 49

printf("\nfor week %d:",i+1); for(j=0; j<pd; j++) { printf("\n Please enter the quantitiy of item number %d :=" ,j+1); fflush(stdin); scanf("%d",&p[i][j]); } } clrscr(); printf("\nweekly purchased items of matrix\n");

## printf("\nplease input the cost of items");

for(i=0; i<1; i++) { for(j=0; j<pd; j++) { printf("\n Please enter the cost price of items %d :=",j+1); fflush(stdin); scanf("%d",&cp[i][j]); } }

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 39 of 49

## printf("\nplease enter the selling price of items");

for(i=0; i<1; i++) { for(j=0; j<pd; j++) { printf("\nPlease enter the selling price of items %d :=",j+1); fflush(stdin); scanf("%d",&sp[i][j]); } }

printf("\nselling price of items\n"); for(i=0; i<1; i++) { for(j=0; j<pd; j++) { printf("%d ",sp[i][j]); } getch(); }

l1: clrscr();

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 40 of 49

## printf("\n \t\t\t\t WELCOME TO SHOPPING MALL MANAGEMENT \t\t\n");

printf("\n press [1] for weekly sale of any products "); printf("\n press [2] for weekly purchase of any products "); printf("\n press [3] for monthly sale of any products"); printf("\n press [4] for monthly purchase of any products");

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 41 of 49

case 4:

case 5:

case 6:

case 7:

case 8:

case 9:

## clrscr(); MSAP(); break;

case 10: clrscr(); MPAP(); break; case 11: clrscr(); CPOAP(); break; case 12: clrscr(); SPAP(); break; case 13: clrscr(); TVOWPS(); break; case 14: clrscr(); TVOMPS(); break;

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 42 of 49

case 15: clrscr(); SOAPAIM(); break; case 16: exit(1); break; default : clrscr(); printf("\n*********** YOU HAVE ENTERED INVALID INPUT ***********\n"); getch(); goto l1; } printf("\n DO U WANT AGAIN [Y/N]"); fflush(stdin); scanf("%c",&chrctr); if(chrctr== 'y' || chrctr== 'Y') goto l1; else { clrscr(); printf("\n ************** THANKING YOU ****************\n"); } getch(); }

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 43 of 49

## fflush(stdin); scanf("%d",&q); printf("\nweekly sale of product no: %d>: %d" ,q,s[p-1][q-1]); }

void WPOAP() { int r,s; printf("enter a week number>:\n"); fflush(stdin);scanf("%d",&r); printf("enter a product number>:\n"); fflush(stdin);scanf("%d",&s); printf("\nweekly purchase of product no: %d>: %d" ,s,p[r-1][s-1]); }

void MSOAP() { int i,j,n,msmas; printf("enter a product number>:\n"); fflush(stdin);scanf("%d",&n); msmas=0; for(i=0; i<4; i++) { for(j=n-1; j<n; j++) { msmas=msmas+s[i][j]; } } printf("\nmonthly sele of product no: %d>: %d" ,n,msmas); }

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 44 of 49

void MPOAP() { int i,j,n,msmap; printf("enter a product number>:\n"); fflush(stdin);scanf("%d",&n); msmap=0; for(i=0; i<4; i++) { for(j=n-1; j<n; j++) { msmap=msmap+p[i][j]; } } printf("\nmonthly purchase of product no: %d>: %d" ,n,msmap); }

void CPOAP() { int j,n; printf("enter the product number>:\n"); fflush(stdin);scanf("%d",&n); printf("cost price of product no: %d>: %d" ,n,cp[0][n-1]); }

void SPOAP() { int j; printf("enter the product number>:\n"); fflush(stdin);scanf("%d",&j); printf("\nsale price of product no: %d>: %d" ,j,sp[0][j-1]); }

void WSAP()

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 45 of 49

{ int p,q,n,wsmals; printf("enter the week number>:\n"); fflush(stdin);scanf("%d",&n); wsmals=0; for(p=n-1; p<n; p++) { for(q=0; q<pd; q++) { wsmals=wsmals+s[p][q]; } } printf("all products sele in %d week>: %d ",n,wsmals); }

void WPAP() {

int r,s,n,wsmalp; printf("enter the week number>:\n"); fflush(stdin);scanf("%d",&n); wsmalp=0; for(r=n-1; r<n; r++) { for(s=0; s<pd; s++) { wsmalp=wsmalp+p[r][s]; } } printf("all products purchase in %d week>: %d ",n,wsmalp); }

void MSAP()

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 46 of 49

{ int m,n,msmals; msmals=0; for(m=0; m<4; m++) { printf("\n"); for(n=0; n<pd; n++) { msmals=msmals+s[m][n]; } } printf("monthly sale of all products>:%d " ,msmals); }

void MPAP() { int i,j,msmalp; msmalp=0; for(i=0; i<4; i++) { printf("\n"); for(j=0; j<pd; j++) { msmalp=msmalp+p[i][j]; } } printf("monthly purchase of all products>:%d " ,msmalp); }

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 47 of 49

for(i=0; i<1; i++) { for(j=0; j<pd; j++) { cpsum=cpsum+cp[i][j]; } } printf("cost price of all products>: %d " ,cpsum); }

void SPAP() { int i,j,spsum; spsum=0; for(i=0; i<1; i++) { for(j=0; j<pd; j++) { spsum=spsum+sp[i][j]; } } printf("sele price of all products>: %d " ,spsum); }

void TVOWPS() { int i,j,sump,sums,n; printf("\nenter a week number>:"); fflush(stdin);scanf("%d" ,&n); sump=0; sums=0; for(i=n-1; i<n; i++) {

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 48 of 49

for(j=0; j<pd; j++) { sump=sump+(p[i][j]*cp[0][j]); sums=sums+(s[i][j]*sp[0][j]); } } printf("total value of weekly purchase products= %d ",sump); printf("total value of weekly sale products= %d ",sums); }

## void TVOMPS() { int i,j,smp,sms;

smp=0; sms=0; for(i=0; i<4; i++) { for(j=0; j<pd; j++) { smp=smp+(p[i][j]*cp[0][j]); sms=sms+(s[i][j]*sp[0][j]); } } printf("total value of monthly purchase products= %d ",smp); printf("total value of monthly sale products= %d ",sms); } void SOAPAIM() { int i,j,sm,sm1,sb,n; printf("Enter the product number:>"); scanf("%d",&n); sm=0;

Level 1

2014

## Software for Engineers CE00554-1

Individual Assignment

Page 49 of 49

for(i=0; i<4; i++) { printf("\n"); for(j=n-1; j<n; j++) { sm=sm+p[i][j]; } } printf("monthly purchase of products no %d> :%d " ,n,sm); sm1=0; for(i=0; i<4; i++) { printf("\n"); for(j=n-1; j<n; j++) { sm1=sm1+s[i][j]; } } printf("monthly sale of products no %d >:%d " ,n,sm1); sb=sm-sm1; printf("\n Stock of product no %d avilable in the mall>: %d ",n,sb); }

Level 1

2014