#include <stdio.h>
#include <stdlib.h>

// Define the structure for a node in the binary tree
struct Node {
    int data;
    struct Node* left;
    struct Node* right;
};


struct Node* newNode(int data) {
    struct Node* node = (struct Node*)malloc(sizeof(struct Node));
    node->data = data;
    node->left = NULL;
    node->right = NULL;
    return node; 
}


void inOrder(struct Node* node) {
    if (node == NULL) {
        return;
    }
    inOrder(node->left);    
    printf("%d ", node->data); // Print the data
    inOrder(node->right);   // Traverse right subtree
}

// Main function
int main() {
    // Create the binary tree
    struct Node* root = newNode(1);
    root->left = newNode(2);
    root->right = newNode(3);
    root->left->left = newNode(4);
    root->left->right = newNode(5);
    root->right->left = newNode(6);
    root->right->right = newNode(7);
    
    // Print the in-order traversal of the binary tree
    printf("Traversal of Binary Tree: ");
    inOrder(root);
    printf("\n");

    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: