What are inline functions? What is the syntax for defining an inline function?
1161
Why is it called c++?
1038
When there is a global variable and local variable with the same name, how will you access the global variable?
1101
Why it is called runtime polymorphism?
1137
Differentiate between a copy constructor and an overloaded assignment operator.
1084
What are the benefits of c++?
1056
What is difference between array and vector in c++?
1030
What is flag in computer?
1055
What is format for defining a structure?
1086
They started with the brief introduction followed by few
basic C++ questions on polumorphism, inheritance and then
virtual functions.
What is polymorphims?
How you will access polymorphic functions in C?
How virtual function mechanism works?
1921
What is meant by const_cast?
1130
What is std :: endl?
1035
What is a class and object?
1055
What is RTTI and why do you need it?
1071
#include
#include
#include
#include
void insert(struct btreenode **, int);
void inorder(struct btreenode *);
struct btreenode
{
struct btreenode *leftchild;
struct btreenode *rightchild;
int data;
};
main()
{
struct btreenode *bt;
bt=(struct btreenode *)NULL;
int req,i=1,num;
clrscr();
printf("Enter number of nodes");
scanf("%d",&req);
while(i<=req)
{
printf("Enter element");
scanf("%d",&num);
insert(&bt,num);
i++;
}
inorder(bt);
}
void insert(struct btreenode **sr, int num)
{
if(*sr==NULL)
{
*sr=(struct btreenode *)malloc (sizeof(struct btreenode));
(*sr)->leftchild=(struct btreenode *)NULL;
(*sr)->rightchild=(struct btreenode *)NULL;
(*sr)->data=num;
return;
}
else
{
if(num < (*sr)->data)
insert(&(*sr)->leftchild,num);
else
insert(&(*sr)->rightchild,num);
}
return;
}
void inorder(struct btreenode *sr)
{
if(sr!=(struct btreenode *)NULL)
{
inorder(sr->leftchild);
printf("\n %d",sr->data);
inorder(sr->rightchild);
}
else
return;
}
please Modify the given program and add two methods for post
order and pre order traversals.
3762