[algogeeks] do while problem

2011-07-29 Thread nullpointer
#includestdio.h void add(); void subtract(); int main() {int choice; printf(enter your choice:1.add 2.subtract:); scanf(%d,choice); switch(choice) {case 1: add(); break; default: printf(wrong choice entered); } } void add() {int a,b; char c; do {printf(enter two numbers:);

[algogeeks] Re: self referential struct. Contd.

2011-07-29 Thread nullpointer
#includestdio.h #includeconio.h struc MyStructA { char a; char b; int c; }; struct MyStructB { char a; int c; char b; }; int main(void) { struct MyStructA A; struct MyStructB B; int sizeA = sizeof(struct MyStructA); int sizeB = sizeof(struct MyStructB); return 0; } OUTPUT IS A = 8

[algogeeks] fibonacci

2011-07-24 Thread nullpointer
#includestdio.h main() {int a,b,n,fib=0; a=0,b=1; scanf(%d,n); if(n==0||n==1) printf(%d\n,n); while(n--!=0) { fib=a+b; a=b; b=fib; printf(%d+,fib); } } for n = 3 o/p is 1+2+3+ how to remve that extra '+' at the end of 3 so that o/p become 1+2+3 -- You received this message because you are

[algogeeks] recursion ???

2011-07-24 Thread nullpointer
#include stdio.h #include string.h void printit(char line_of_char[], int index); int main() { char line_of_char[80]; int index = -1; strcpy(line_of_char, 1234567890); printit(line_of_char, index); return 0; } void printit(char line_of_char[], int index) { if(line_of_char[index]) { index++;