Online C Compiler - online editor
Sat Dec 07 2024 08:58:43 GMT+0000 (Coordinated Universal Time)
Saved by @Narendra
#include<stdio.h> #include<stdlib.h> struct TreeNode{ int data; struct TreeNode *left , *right ; }; struct TreeNode* createNode(int data) { struct TreeNode *newNode = (struct TreeNode*)malloc(sizeof(struct TreeNode)); newNode->data = data; newNode->left = newNode->right = NULL; return newNode; } int main() { struct TreeNode *dll = createNode(10); dll->left = createNode(3); dll->right = createNode(6); printf("Root data: %d\n", dll->data); printf("Left child data: %d\n", dll->left->data); printf("Right child data: %d\n", dll->right->data); return 0 ; }
https://www.onlinegdb.com/online_c_compiler
Comments