Tuesday, June 4, 2019

Procedure Oriented Programming

Procedure Oriented ProgrammingSubmitted by Gagandeep Singh BrarProcedure oriented programing is a set of functions. In this program Clanguage is used. To perform any particular task, set of function atomic number 18 compulsory. For example , a program may collect salt away data from user, performing some kind of calculation on that data and make the data on screen when is requested. Calculating, reading or printing can be written in a program with the help of different functions on different tasks.POP method also emphases the functions or the subroutines. mental synthesis of POP methodHere is some problems in POP method like its difficult to handling data because it gives no importance to data. Dat message the information that are collected from user and after calculation new result come. If any unrivaled is familiar with C programming than he may recollect storage classes in C. In C, data member is declared GLOBAL in order to make 2 or more functions in the program. What ha ppen when 2 or functions on the same data member. For example, when if there are 7 functions in a program and this become a world(a) data member. Unfortunately, if the value of any global data member or that may key element than it will affect the whole program. It is a plumping problem to identify that which function is causing the problem.Handling of data functions in POPOne of the most important feature 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 first by c language.Object Oriented ProgrammingAn OOP method differs from POP in its basal approach itself. All the best features of structured of OOP is developed by retaining the programming method, in which they have summateed number of concepts which makes efficient programming. Object oriented programming methods have number of features and it makes possible an entirel y new way 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 hiding facility. Programmer can hide the important core data from external world by using OOP method. The basic concept of OOP revolves around a feature similar to structure in POP, named 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. collectable to same structure, a class packs together different things into a single entity.2) Another important feature of OOP is code reusability. The simple means of code reusability is adept that the code is written earlier in program or read or used it later. This is made possible by a feature of classes named inheritance. By using inheritance, one class can acquire the properties of another class. Let i will try to expl ain this using an example. Take the example of a School Management System and management decided to make software based on the data of students only. The programmer made the software and deciding to collecting personal details like Name, Age, Sex, Address etc. After one year school management decides to incorporate data of teachers to the software. The programmer can add this extension within a small time as he can reuse many of the codes he had written earlier by make 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 fileFILE *fp1gagan //temporary file struct st_record int id char fname20 char lname20 char class_name20 char address40 char phone12 char email20 struct st_record s1 debar main() menu()menu() int choice printf(nPress 1 to create a new record) printf(nPress 2 to edit an existing record) printf( nPress 3 to search records) printf(nPress 4 to delete a record) printf(nPress 5 to exhale 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 enter 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, be make up = 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(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(fp1gagan) remove(students.txt) rename(students1.txt,students.txt) if(found=1) printf(Not found) getch() menu()sear ch_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(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.e mail) 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 modify 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

Note: Only a member of this blog may post a comment.