- Type
- Quiz
- Course
- CS205 Information Security
- Size
- PDF 2.5 MB
- Updated
- 23 Oct 2026
You get 3 free files a day on the website. Add the Chrome extensionSign in with the extension for 30 a day.
Preview text
Text from pages 1, 2, 3 of 15. Download the file for all 15 pages.
Programming style
Procedural programming is a paradigm based on the concept of using procedures. Procedure (sometimes also called subprogram, routine or method) is a sequence of commands to be executed. Any procedure can be called from any point within the general program, including other procedures or even itself *re-usability of pieces code designed as procedures *ease of following the logic of program; *Maintainability of code. *Emphasis is on doing things (algorithms). *Most of the functions share global data. *Data move openly around the system from function to function. *Functions transform data from one form to another. Modular Programming is progressively decomposed into smaller partition called modules. The program can easily be written in modular form, thus allowing an overall problem to be decomposed into a sequence of individual sub programs. Thus we can consider, a module decomposed into successively subordinate module. Conversely, a number of modules can combined together to form a superior module. *Define the problem *Outline the steps needed to achieve the goal *Decompose the problem into subtasks *Prototype a subprogram for each sub task *Repeat step 3 and 4 for each subprogram until further decomposition seems counter productive
Advantages
*Reduce the complexity of the entire problem *Avoid the duplication of code *debugging program is easier and reliable *Improves the performance *Modular program hides the use of data structure *Global data also hidden in module *Reusabilitymodules can be used in other program without rewriting and retesting *Modular program improves the portability of program *It reduces the development work
Top- down modular programming
The principles of top-down design dictate that a program should be divided into a main module and its related modules. Each module should also be divided into sub modules according to software engineering and programming style. The division of modules processes until the module consists only of elementary process that are intrinsically understood and cannot be further subdivided. Bottom-up algorithm design is the opposite of top-down design. It refers to a style of programming where an application is constructed starting with existing primitives of the programming language, and constructing gradually more and more complicated features, until the all of the application has been written.
Structured Programming
It is a programming style; and this style of programming is known by several names: Procedural decomposition, Structured programming, etc. Structured programming is not programming with structures but by using following types of code structures to write programs: *Sequence of sequentially executed statements *Conditional execution of statements (ie., "if statements) *Looping or iteration (ie., "for, do...while, and while" statements) *Structured subroutine calls {ie., functions)
Advantages
1. clarity: structured programming has a clarity and logical pattern to their control
MODULE 1
structure and due to this tremendous increase in programming productivity
- another key to structured programming
is that each block of code has a single entry point and single exit point.so we can break up long sequence of code into modules
- Maintenance: the clarity and
modularity inherent in structured programming is of great help in finding an error and redesigning the required section of code.
0bect Oriented Programming
The major motivating factor in the invention of object-oriented approach is to remove some of the flaws encountered in the procedural or modular approach. OOP treats data as a critical element in the program development and does not allow it to flow freely around the system. It ties data more closely to the function that operate on it, and protects it from accidental modification from outside function.
FEATURES
•Emphasis is on data rather than procedure. •Programs are divided into what are known as objects. •Data structures are designed such that they characterize the objects. •Functions that operate on the data of an object are ties together in the data structure. •Data is hidden and cannot be accessed by external function. •Objects may communicate with each other through function. •New data and functions can be easily added whenever necessary. •Follows bottom up approach in program design
Array
*Elements are always stored at continuous / contiguous memory locations. *No need to store the address of the next element. *Uses the concept of Static Memory Allocation. *All the required memory needs to be allocated in advance. *Has a fixed dimension. So cannot grow or shrink at run time. *Operations like Insertion and Deletion are time-consuming. *They might require major shifting of elements.
Linked List
*Elements might be stored at discontinuous memory locations. *Need to store the address of the next element along with the value. *Uses the concept of Dynamic Memory Allocation. *Memory can be allocated on demand and not in advance. *Can always grow or shrink at run time. *Operations like Insertion and Deletion are simple and less time-consuming. *Shifting of elements is not required. Only adjustment of links are required. Frequency count method can be used to analyze a program .Here we assume that every statement takes the same constant amount of time for its execution.
scanf(“%d”,&n); printf(“Enter the Elements\n”); for(i=0;i<n;i++) ,{
{ ,printf(“Enter the element to be inserted”) scanf(“%d”,&p); ,for(i=n-1;i>=0;i--) ,{ a[i+1]=a[i]; ,} ,n=n+1 ,a[0]=p;
} ,} ,getch(); ,}
insert an element into the end of
an array
scanf("%d",&n); ,printf(" Enter
scanf("%d",&p); ,a[n+l]=p; ,n=n+l;
} ,} ,getchO; ,}
Insert An Element Into The
Particular Position of an array
#include <stdio.h> ,int main() { ,int array[100], position, c, n, value; printf(" Enter number of elements in array\n"); ,scanf("%d", &n); printf(" Enter %d elements\n", n); for (c = 0; c < n; C++) scanf("%d", &array[c]); printf(" Enter the location where you wish to insert an element\n"); scanf("%d", &position); ,if(position>=100)
printf(" Enter the value to insert\n"); scanf("%d", &value); for (c = n - 1; c >= position - 1; c~) array[c+l] = array[c]; array[position-l] = value; ,n=n+l;
for (c = 0; c <=n; C++) printf("%d\n", array[c]); ,} ,getchO; ,}
Delete An Element From The Beginning Of An Array
,scanf("%d",&n); printf("enter the elements\n"); for(i=0;i<n;i++) ,{ ,scanf("%d",&a[i]); } ,p=a[0]; ,for(i=l;i<n;i++) ,{ a[i-l]=a[i]; ,} ,n=n-l; printf("deleted elements are %d",p); if(n==0) ,printf("array is empty"); ,else ,{ printf("after deletion elements are:\n");
} } ,getcho; ,}
Delete An Element From The End
int main() ,{ ,int a[10],i,n;
scanf("%d",&a[i]); ,} ,p=a[n]; printf(" Deleted element is %d",p); n=n-l; ,if(n==0) ,printf(" Array is empty"); else ,{ printf(" After deletion elements are:\n");
} ,getchO; ,}
Delete An Element From The Particular Position Of An Array
#include <stdio.h> ,int main() ,{ int array[100], position, c, n, value; printf(" Enter number of elements in array\n"); scanf("%d", &n); printf(" Enter %d elements\n", n); for (c = 0; c < n; C++) ,scanf("%d", &array[c]); printf(" Enter the location where you wish to delete an element\n");scanf("%d", &position); value=array[position-1 ]; for (c = position; c >n; c~) array[c-l] = array [c];
Related CS205 files
All CS205 files →Get more out of VUBuddy, for free
- Unlimited downloads
- The explanation behind every MCQ answer
- Study offline on slow data
- 30 downloads a day instead of 3
- Sign in and buy Pro Semester here
One Pro Semester membership works in both the extension and the app.