[algogeeks] standard puzzle
There are 10 coins in a bag. 3 coin weights x kg 3 coins weights y kg 2 coins weights z kg 2 coins weights w kg You have to separate them into separate heaps according to their weights. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] standard puzzle
u have to separate them into 4 heaps in min number of comparisons . given a weighing balance On Sun, Jun 10, 2012 at 12:05 PM, Saurabh Yadav saurabh...@gmail.comwrote: question is incomplete , mention the conditions please On Sun, Jun 10, 2012 at 11:44 AM, HARSHIT PAHUJA hpahuja.mn...@gmail.comwrote: There are 10 coins in a bag. 3 coin weights x kg 3 coins weights y kg 2 coins weights z kg 2 coins weights w kg You have to separate them into separate heaps according to their weights. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks Regards Saurabh Yadav -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] override struct definition in c ????
is it possible to override struct definition in c in header.h header file i have eg typedef struct a { int ab ; } nw in .c file i have included header.h typedef struct a { char c ; int b; } and giving following def i m getting an error ... *'struct type redefinition'* So anyways in c anyways to override this error , like in c++ or c# we use virtual keyword -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Microsoft interview question
given 2 unsorted integer arrays a and b of equal size. Determine if b is a permutation of a. Can this be done in O(n) time and O(1) space ? please help me with my solution suppose a -- 3 5 4 b -- 4 3 5 now we replace a[i] with a[i]..th prime number and b with b[i] .. th prime number now array a becomes 5 11 7 array b becomes 7 5 11 now we take product of elements of array a and do the same with array b elements if product is equal then b is a permutation of a -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Microsoft interview question
@malay --- we can do it by precomputing the prime arrays On Sun, May 20, 2012 at 1:10 AM, malay chakrabarti m1234...@gmail.comwrote: method is ryt but to find ith prime u cannot to it in constant time. On May 19, 2012 7:30 PM, HARSHIT PAHUJA hpahuja.mn...@gmail.com wrote: given 2 unsorted integer arrays a and b of equal size. Determine if b is a permutation of a. Can this be done in O(n) time and O(1) space ? please help me with my solution suppose a -- 3 5 4 b -- 4 3 5 now we replace a[i] with a[i]..th prime number and b with b[i] .. th prime number now array a becomes 5 11 7 array b becomes 7 5 11 now we take product of elements of array a and do the same with array b elements if product is equal then b is a permutation of a -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Check if one tree is sub tree of other
bool isSubtree(Tree * A,Tree *B) { if(!B) return true; if(!A)return false; if(A-data==B-data) return (isSubtree(A-left,B-left) isSubtree(A-right,B-right)); else return (isSubtree(A-left,B) isSubtree(A-right,B)); } } On Wed, Mar 21, 2012 at 2:33 AM, Don dondod...@gmail.com wrote: bool equals(node *t1, node *t2) { return (t1 t2) ? (t1-value == t2-value) equals(t1-left, t2- left) equals(t1-right, t2-right) : !t1 !t2; } bool check(node *t1, node *subtree) { return t1 ? equals(t1, subtree) || check(t1-left, subtree) || check(t1-right, subtree) : !subtree; } On average this is the same as a traversal, but worst case could be very slow. Imagine a large tree with millions of nodes, where all the nodes = 1, and a somewhat smaller subtree with 100,000 nodes=1 and one node at the far right of the tree = 2. It would require a lengthy comparision at each node which would ultimately find no matching sub tree. If they are binary search trees, it could be more efficient. Did you mean to ask about binary search trees? Don On Mar 20, 7:24 am, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: How to check if one binary tree is a sub tree of other? Any Solution other then bruteforce? Prototype bool check(node *t1,node *subtree) -- Sent from my mobile device *Dheeraj Sharma* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] c output ??
*#includestdio.h int main() { float f=25.25; printf(%d\n,f); long int x=90; printf(%f,x); return 0; } * above program gives output *0 25.25* shudn it be : *25 90.* ?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: POWER CRISES :Spoj
@rizwaan u r ryt bt i want a O(n) soln .. whats say On Wed, Jun 29, 2011 at 2:55 PM, rizwan hudda rizwanhu...@gmail.com wrote: http://ideone.com/MSLXT The constraints are so less that you can brute force the solution..N100. My solution is O(N^3) On Thu, Jun 30, 2011 at 1:13 AM, harshit pahuja hpahuja.mn...@gmail.com wrote: http://en.wikipedia.org/wiki/Josephus_problem here there is an explanation of the derivation of josephus which is nt very clearcan some1 explain it plzz On Wed, Jun 29, 2011 at 12:40 PM, harshit pahuja hpahuja.mn...@gmail.com wrote: Hello guys... http://www.spoj.pl/problems/POCRI/ this problem is using a variant of josephus problem. in josephus we for given n persons in a circle we start killing every kth person and last person remaining is the survivor..kth 2kth 3kth...so on i solved it using f(n,k)=(f(n-1,k)+k)%m nd dp... nw in its variant which is the spoj problem we have to kill evert kth person but we have to start by killing 1st den (k+1)th den(2k+1)th so on i m nt able to modify the above problem plzz help -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks and regards Rizwan A Hudda http://sites.google.com/site/rizwanhudda2 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] POWER CRISES :Spoj
Hello guys... http://www.spoj.pl/problems/POCRI/ this problem is using a variant of josephus problem. in josephus we for given n persons in a circle we start killing every kth person and last person remaining is the survivor..kth 2kth 3kth...so on i solved it using *f(n,k)=(f(n-1,k)+k)%m nd dp...* * * nw in its variant which is the spoj problem we have to kill evert kth person but we have to start by killing 1st den (k+1)th den(2k+1)th so on i m nt able to modify the above problem plzz help -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: POWER CRISES :Spoj
http://en.wikipedia.org/wiki/Josephus_problem here there is an explanation of the derivation of josephus which is nt very clearcan some1 explain it plzz On Wed, Jun 29, 2011 at 12:40 PM, harshit pahuja hpahuja.mn...@gmail.comwrote: Hello guys... http://www.spoj.pl/problems/POCRI/ this problem is using a variant of josephus problem. in josephus we for given n persons in a circle we start killing every kth person and last person remaining is the survivor..kth 2kth 3kth...so on i solved it using *f(n,k)=(f(n-1,k)+k)%m nd dp...* * * nw in its variant which is the spoj problem we have to kill evert kth person but we have to start by killing 1st den (k+1)th den(2k+1)th so on i m nt able to modify the above problem plzz help -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: spoj shlights
hint is : go for counting ,not for shifting o(n). :P On Mon, Jun 27, 2011 at 9:29 PM, pacific :-) pacific4...@gmail.com wrote: Can one of you provide some hints in solving this problem ? On Sat, Jun 25, 2011 at 3:34 PM, kartik sachan kartik.sac...@gmail.comwrote: @jitendra that's what i am asking forwhat algo i should implement to get process in 1 sec? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- regards, chinna. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: puzzle
hw u r gettin 3 i m gettin 4 mine is make 4 grups 1,2,6 no 1 2,3,5 no 2 1,3,4 no 3 4,5,6no 4 nw out of 4 2 mice will die,and in their corresponding groups common bottle will give you the answer. correct me if i am wrong -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: puzzle
i got it :) nice @dev!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] output plzz
#includestdio.h #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0])) int array[] = {23,34,12,17,204,99,16}; int main() { int d; for(d=-1;d = (TOTAL_ELEMENTS-2);d++) printf(%d\n,array[d+1]); return 0; } y der is nothing in the output . - Regards - HARSHIT PAHUJA -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Segmentation fault
this is ma code for http://www.spoj.pl/problems/ANARC08H/musical chairs i m using dynamic programming for input lik 20 20 i m getting seg. fault plz tell hw to modify my program #includeiostream #includecstdio using namespace std; long long arr[10003][10003]; long long f(int n,int k) { if(n==1) return 0; else { //if(arr[n][k]) return arr[n][k]; return /* arr[n][k] = */(f(n-1,k)+k)%n ; } } int main() { int n,k; scanf(%d%d,n,k); //cinnk; while(n k) { printf(%d %d %lld\n,n,k,f(n,k)+1); //coutf(n,k)+1; scanf(%d%d,n,k); } return 0; } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Segmentation fault
@piyush using array is mecessary as constraints are n,d100 so recursion cannot go to that much depth as we have stack limits what do u suggest -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Segmentation fault
got it :) AC used single array nd got the job done.. On Thu, Jun 23, 2011 at 4:22 AM, harshit pahuja hpahuja.mn...@gmail.comwrote: @piyush using array is mecessary as constraints are n,d100 so recursion cannot go to that much depth as we have stack limits what do u suggest -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c doubt again
@anika can u will please tell me the source of all dese questions,, actually i am new to this all nd getting to learn a lot.. thanks in anticipation On Thu, Jun 23, 2011 at 7:52 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: sorry by mistake i added it in scanf situation.. actually this type of specifier can be used with printf statement for finding the sum... look at the code below main() { int a=9; int b=3; printf(%d\n,printf(%*s%*s,a,,b,)); system(pause); } On 6/23/11, Anika Jain anika.jai...@gmail.com wrote: thanx .. can u explain me how this is used in finding sum of 2 vars without using + ?? On Thu, Jun 23, 2011 at 7:20 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: An asterisk indicates that the data is to be retrieved from the use but ignored, i.e. it is not stored in the corresponding argument...hence the third value entered gets stored for b and for c the output comes to garbage value One beautiful application of such type of implementation is in finding the sum of 2 variables without using + operator..:) On 6/23/11, Anika Jain anika.jai...@gmail.com wrote: int main() { int a,b, c; scanf(%d%*d%d,a,b,c); printf(%d %d %d,a,b,c); } output: 25 35 garbage how is it happening?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c doubt again
this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Segmentation fault
i meant take a 1d array..as k is the constant for a single test case... On Thu, Jun 23, 2011 at 9:46 PM, anonymous procrastination opamp1...@gmail.com wrote: @Harshit Please explain what do you mean by single array? I'm trying to solve the same problem. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: If any one have algorithms for interviews by adnan aziz ebook... Please mail ...
options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thank You Rajeev Kumar -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c doubt again
@anika -thankx :) On Thu, Jun 23, 2011 at 11:57 AM, Anika Jain anika.jai...@gmail.com wrote: @ harshit: i find such questions from books like let us c, test ur c, dennis ritchie and from test papers of companies that visit campus On Thu, Jun 23, 2011 at 9:15 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote: or u cud consult ANSI C by Balaguruswamy in chapter of Console I/Ps and O/Ps On 6/23/11, harshit pahuja hpahuja.mn...@gmail.com wrote: @rajeev http://www.cplusplus.com/reference/clibrary/cstdio/scanf/ http://www.cplusplus.com/reference/clibrary/cstdio/printf/ On Thu, Jun 23, 2011 at 9:39 PM, rajeev bharshetty rajeevr...@gmail.comwrote: @ Piyush Could u provide the link to some source , because i am still unclear about the above concept . Regards Rajeev N B On Thu, Jun 23, 2011 at 8:32 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: there is no as such logic behind it..its just the format specifier... u must be knowing printf returns the number of values it has printed(u can check that) now, in printf if u write like *printf(%7s,a), *it will create 7 columns for the output and print a in the last column and the returned value of this printf will be 7..(u can check it) now if u write *printf(%*s,7,a)* then u r giving additional information of format specifier i.e 7..returned value of this printf is also 7. Hence the above logic..hope I am able to clarify it...:) On Thu, Jun 23, 2011 at 8:06 PM, Anika Jain anika.jai...@gmail.comwrote: i mean how it working actually? On Thu, Jun 23, 2011 at 8:06 PM, Anika Jain anika.jai...@gmail.comwrote: hey ya its working :) but whats the logic behind it?? On Thu, Jun 23, 2011 at 7:52 PM, Piyush Sinha ecstasy.piy...@gmail.com wrote: sorry by mistake i added it in scanf situation.. actually this type of specifier can be used with printf statement for finding the sum... look at the code below main() { int a=9; int b=3; printf(%d\n,printf(%*s%*s,a,,b,)); system(pause); } On 6/23/11, Anika Jain anika.jai...@gmail.com wrote: thanx .. can u explain me how this is used in finding sum of 2 vars without using + ?? On Thu, Jun 23, 2011 at 7:20 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: An asterisk indicates that the data is to be retrieved from the use but ignored, i.e. it is not stored in the corresponding argument...hence the third value entered gets stored for b and for c the output comes to garbage value One beautiful application of such type of implementation is in finding the sum of 2 variables without using + operator..:) On 6/23/11, Anika Jain anika.jai...@gmail.com wrote: int main() { int a,b, c; scanf(%d%*d%d,a,b,c); printf(%d %d %d,a,b,c); } output: 25 35 garbage how is it happening?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com . To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group