Posts

Showing posts from December, 2024

Write a program to reverse an array

Reverse an Array Program to Reverse an Array in C #include <stdio.h> void reverseArray(int arr[], int size) { int start = 0, end = size - 1, temp; while (start < end) { // Swap the elements temp = arr[start]; arr[start] = arr[end]; arr[end] = temp; start++; end--; } } int main() { int n, i; printf("Enter the size of the array: "); scanf("%d", &n); int arr[n]; printf("Enter %d elements:\n", n); for (i = 0; i < n; i++) { scanf("%d", &arr[i]); } reverseArray(arr, n); printf("Reversed array:\n"); for (i = 0; i < n; i++) { printf("%d ", arr[i]); } return 0; } Sample Output Enter the size of the array: 5 Enter 5 elements: 1 2 3 4 5 Reversed array: 5 4 3 2 1

Abstraction versus Decomposition

Abstraction vs Decomposition in Software Engineering Abstraction vs Decomposition in Software Engineering Abstraction Definition: Abstraction focuses on hiding the unnecessary details and complexities of a system to present only the essential features and behavior. It allows developers to work with higher-level concepts without worrying about the implementation specifics. Purpose: Simplify complex systems by reducing the amount of information to process. Example: A class interface in object-oriented programming provides methods without exposing how they are implemented internally. A database query hides the underlying file storage and retrieval mechanisms. Usage: Often used in system design, modeling, and software architecture (e.g., UML diagrams, abstract classes, APIs). Key Question it Addresses: "What does the system/component do?" Decomposition Definition: Decompositio...