Write a program that find and print how many odd numbers in
a binary tree



Write a program that find and print how many odd numbers in a binary tree..

Answer / raghuram.a

struct node
{
int data;
struct node *l;
struct node *r;
};
typedef struct node *n;
int oddnos(n root)
{
static int count;
n cur = root;
if(cur!=NULL)
{
if(cur->data%2==1)
count++;
oddnos(root->l);
oddnos(root->r);
}
return count;
}

Is This Answer Correct ?    8 Yes 5 No

Post New Answer

More C Code Interview Questions

Who could write how to find a prime number in dynamic array?

1 Answers  


Write a Program in 'C' To Insert a Unique Number Only. (Hint: Just Like a Primary Key Numbers In Database.) Please Some One Suggest Me a Better Solution for This question ??

0 Answers   Home,


Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution)

7 Answers   Microsoft,


could you please send the program code for multiplying sparse matrix in c????

0 Answers  


Cau u say the output....?

1 Answers  






main() { if ((1||0) && (0||1)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above

5 Answers   HCL,


main() { int i, n; char *x = “girl”; n = strlen(x); *x = x[n]; for(i=0; i<n; ++i) { printf(“%s\n”,x); x++; } }

2 Answers  


char *someFun() { char *temp = “string constant"; return temp; } int main() { puts(someFun()); }

1 Answers  


What is the output of the program given below main() { signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

1 Answers  


void pascal f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } void cdecl f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); }

1 Answers  


Print an integer using only putchar. Try doing it without using extra storage.

2 Answers  


main() { int i=4,j=7; j = j || i++ && printf("YOU CAN"); printf("%d %d", i, j); }

1 Answers  


Categories