.

Monday, April 1, 2019

Procedure Oriented Programming

Procedure Oriented computer programingSubmitted by Gagandeep Singh BrarProcedure lie programing is a set of functions. In this program Clanguage is dropd. To perform every particular task, set of function are compulsory. For example , a program may involve collecting entropy from user, performing some kind of advisement on that info and produce the data on screen when is requested. Calculating, removeing or printing enkindle be written in a program with the help of different functions on different tasks.POP rule also emphases the functions or the subroutines. social structure of POP method present is some problems in POP method like its difficult to handling data because it gives no importance to data. digital audiotape means the information that are collected from user and after calculation new result come. If any one is familiar with C programming than he may recollect storage sectionalisationes in C. In C, data member is declared GLOBAL in order to make 2 or more fun ctions in the program. What happen when 2 or functions on the aforementioned(prenominal) data member. For example, when if there are 7 functions in a program and this become a global data member. Unfortunately, if the value of any global data member or that may key component part than it will affect the whole program. It is a big problem to set that which function is causing the problem.Handling of data functions in POP unmatchable of the most important trait of C language is structure. Programmer use integer data, decimal point data(float), array data pack together into single entity by using structure. The reason of the popularity of structure was introduced initial by c language.Object Oriented ProgrammingAn OOP method differs from POP in its basic approach itself. All the lift out features of structured of OOP is developed by retaining the programming method, in which they have added number of concepts which makes efficient programming. Object oriented programming method s have number of features and it makes possible an entirely new modality of approaching a program. We have to mind first that OOP retains all best features of POP method like functions/sub routines, structure etc.1) The first feature that any programmer would talk about OOP is data screen facility. Programmer can hide the important core data from outside world by using OOP method. The basic concept of OOP revolves around a feature similar to structure in POP, progress tod as class in OOP.. Data members can be declared as private or public inside a class. Programmer have to note that a class is really similar to structure in C. Due to alike structure, a class packs together different things into a single entity.2) other important feature of OOP is code reusability. The simple means of code reusability is however that the code is written earlier in program or read or used it later. This is do possible by a feature of classes named inheritance. By using inheritance, one class c an acquire the properties of other class. Let i will try to explain this using an example. think the example of a School Management System and management trenchant to make software based on the data of students only. The programmer made the software and deciding to collecting personal exposit like Name, Age, Sex, comprehend etc. After one year school management decides to hold back data of teachers to the software. The programmer can add this extension within a small time as he can reuse many a(prenominal) of the codes he had written earlier by making use of inheritance. The class personal details is of general nature (Age, Sex etc are same for every person irrespective of student/teacher). ( CircuitsToday, 2015)C codes intromitinclude //1FILE *fpgagan //the actual students tearFILE *fp1gagan //temporary file struct st_ ledger int id char fname20 char lname20 char class_name20 char address40 char phone12 char email20 struct st_ put down s1 unfilled main() menu()menu() int choice printf(nPress 1 to create a new file) printf(nPress 2 to disregard an existing destroy) printf(nPress 3 to search records) printf(nPress 4 to score out a record) printf(nPress 5 to exit this pprogram n) scanf(%d, choice) if(choice == 1) create_fn() else if(choice == 2) edit_fn() else if(choice == 3) search_fn() else if(choice == 4) delete_fn() else if(choice == 5) exit_fn() else printf(nPlease tape the correct choice) menu() create_fn() printf(nStudent ID ) scanf(%d, s1.id) printf(nFirst name ) scanf(%s, s1.fname) printf(nLast name ) scanf(%s, s1.lname) printf(nClass name ) scanf(%s, s1.class_name) printf(nAddress ) scanf(%s, s1.address) printf(nPhone ) scanf(%s, s1.phone) printf(nEmail ) scanf(%s, s1.email) fpgagan=fopen(students.txt,a+) //3 fprintf(fpgagan,n%dt%st%st%st%st%st%s,s1.id,s1.fname,s1.lname,s1.class_name,s1.address,s1.phone,s1.email) //4 fclose(fpgagan) menu()edit_fn() printf(nThis is the edit function) int id1, free-base found = 0 printf(nPlease tape the Student ID ) scanf(%d, id1) if((fpgagan=fopen(students.txt,r))==NULL) printf(Empty) else fp1gagan=fopen(students1.txt,a+) while(feof(fpgagan) found==0) fscanf(fpgagan,n%dt%st%st%st%st%st%s,s1.id,s1.fname,s1.lname,s1.class_name,s1.address,s1.phone,s1.email) if(s1.id==id1) found=1 printf(nStudent record found.) printf(n%dt%st%st%st%st%st%s,s1.id,s1.fname,s1.lname,s1.class_name,s1.address,s1.phone,s1.email) printf(nEnter the new details now) printf(nStudent ID ) scanf(%d, s1.id) printf(nFirst name ) scanf(%s, s1.fname) printf(nLast name ) scanf(%s, s1.lname) printf(nClass name ) scanf(%s, s1.class_name) printf(nAddress ) scanf(%s, s1.address) printf(nPhone ) scanf(%s, s1.phone) printf(nEmail ) scanf(%s, s1.email) fprintf(fp1gagan,n%dt%st%st%st%st%st%s,s1.id,s1.fname,s1.lname,s1.class_name,s1.address,s1.phone,s1.email) continue else fprintf(fp1gagan,n%dt%st%st%st%st%st%s,s1.id,s1.fname,s1.lname,s1.class_name,s1.address,s1.phone,s1.email) fclose(fpgagan) fclose(fp1gaga n) remove(students.txt) rename(students1.txt,students.txt) if(found=1) printf(Not found) getch() menu()search_fn() int id1,found found = 0 printf(nPlease enter the Student ID ) scanf(%d, id1) if((fpgagan=fopen(students.txt,r))==NULL) printf(Empty) else while(feof(fpgagan) found==0) fscanf(fpgagan,n%dt%st%st%st%st%st%s,s1.id,s1.fname,s1.lname,s1.class_name,s1.address,s1.phone,s1.email) if(s1.id==id1) found=1 if(found==1) printf(nStudent record found.) printf(n%dt%st%st%st%st%st%s,s1.id,s1.fname,s1.lname,s1.class_name,s1.address,s1.phone,s1.email) else printf(Not found) getch() menu()delete_fn() printf(nThis is the delete function) int id1,found found = 0 printf(nPlease enter the Student ID ) scanf(%d, id1) if((fpgagan=fopen(students.txt,r))==NULL) printf(Empty) else fp1gagan=fopen(students1.txt,a+) while(feof(fpgagan) found==0) fscanf(fpgagan,n%dt%st%st%st%st%st%s,s1.id,s1.fname,s1.lname,s1.class_name,s1.address,s1.phone,s1.email) if(s1.id==id1) found=1 printf(nStud ent record found.) printf(n%dt%st%st%st%st%st%s,s1.id,s1.fname,s1.lname,s1.class_name,s1.address,s1.phone,s1.email) printf(nRecord deleted) continue else fprintf(fp1gagan,n%dt%st%st%st%st%st%s,s1.id,s1.fname,s1.lname,s1.class_name,s1.address,s1.phone,s1.email) fclose(fpgagan) fclose(fp1gagan) remove(students.txt) rename(students1.txt,students.txt) if(found=1) printf(Not found) getch() menu()exit_fn() printf(nThis is the exit function)Here we are recording three students recordIn this screen short we are able to see the record of the studentsIn this screen shot we try to editing the recordHere we can see the change in the record.Here we try to delete the recordAnd in this screen shot only one record is leftCircuitsToday. (2015). Retrieved from Difference between Procedure Oriented(POP) and Object Oriented Programming(OOP) http//www.circuitstoday.com/difference-between-procedure-oriented-and-object-oriented-programming

No comments:

Post a Comment