Posts
Showing posts from May, 2022
c program to find Binary Tree operations
- Get link
- X
- Other Apps
Program #include <stdio.h> #include <stdlib.h> struct tnode { int data; struct tnode *left, *right; }; struct tnode *root = NULL; struct tnode * createNode(int data) { struct tnode *newNode; newNode = (struct tnode *) malloc(sizeof(struct tnode)); newNode->data = data; newNode->left = NULL; newNode->right = NULL; return (newNode); } void insertion(struct tnode **node, int data) { if (!*node) *node = createNode(data); else if (data < (*node)->data) insertion(&(*node)->left, data); else if (data > (*node)->data) insertion(&(*node)->right, data); } void postOrder(struct tnode *node) { if (node) { postOrder(node->left); postOrder(node->right); printf("%d ", node->data); } return;
Program to find Swap of 2 numbers in c
- Get link
- X
- Other Apps
Program #include <stdio.h> void swap(int*, int*); int main() { int x, y; printf("Enter the value of x : \n"); scanf("%d",&x); printf("Enter the value of y : \n"); scanf("%d",&y); printf("Before Swapping x & y is : \n x = %d \n y = %d \n", x, y); swap(&x, &y); printf("After Swapping x & y is : \n x = %d \ny = %d ", x, y); return 0; } void swap(int *a, int *b) { int temp; temp = *b; *b = *a; *a = temp; } Output
Flowchart Symbols & examples
- Get link
- X
- Other Apps
§ The pictorial representation of an algorithm with specific symbols for instructions & arrows showing the sequence of operations is known as “FLOWCART”. § The basic geometric shapes to denote different types of instructions. And these boxes are connected by solid lines with arrow mark to indicate the flow of operations. § An algorithm is converted into a flowchart & then instructions are expressed in some programming language. § The main advantage of this two-step approach . That is ,while drawing a flowchart one is not concerned with the details of the elements of programming language. § Since a flowchart show of operations in pictorial form, any error in the logic of the procedure can be detected more easily than in a program. FLOWCHART SYMBOLS 1. Terminal § It is used to indicate the beginning (START) & ending (STOP) in the program logic flow. § It has the shape of an ellipse 2. Input/Output § The parallelogram is used as t