[algogeeks] C doubt

2012-10-06 Thread rahul sharma
char ch ch=i++[s]; printf(%c,ch); this will print i[s],then i is incrementrd after assigning to ch ch=++i[s];// this will inccrement value at i[s] My question is what is role of priority which is making them behaving differentI am not getting y not first i is incremented then i[s]

Re: [algogeeks] C doubt

2012-10-06 Thread atul anand
ch=i++[s]; // in this value is assigned first and then increment will take place...bcozz you are using post increment. here i does not have any other option it has to do post increment before [] comes...but it will not assign value to 'i' ( i.e incremented 'i' value) so compiler will do something

Re: [algogeeks] c doubt show me how smart u guys are

2011-09-25 Thread Ashima .
use radix sort 4 times. using bucket sort with chaining as the sorting algorithm. time complexity= O(4(n+k)) space complexity = O(n) Ashima M.Sc.(Tech)Information Systems 4th year BITS Pilani Rajasthan On Sun, Sep 25, 2011 at 6:01 AM, Jasveen Singh jasveen.sing...@gmail.comwrote: i have a

Re: [algogeeks] c doubt show me how smart u guys are

2011-09-25 Thread Jasveen Singh
yes i can do that but how do u want me to proceed if u can give me the code to tell me how to fetch data from the file and use bucket sort on it it will be a huge favour and am i right at my approach to use 2d array to store the values plz tell me sir plz!! On Sun, Sep 25, 2011 at 1:08 PM, Ashima

[algogeeks] c doubt show me how smart u guys are

2011-09-24 Thread Jasveen Singh
i have a file 'star.txt' containing recordss in the form name score as given below *name score* dave 52.67 steve60.09 and so on till 64 names i have to make a program to read and sort these names in a rank just show not to store all scores are in float and need to rank

Re: [algogeeks] c doubt

2011-08-31 Thread PRATEEK VERMA
oh i'm sorry guys galz,its my mistake..actually i forgot to add one more field in struct this is the correct one typedef struct { int bit1:29; int bit2:4; }bit; int main() { printf(%d\n,sizeof(bit)); return 0; } now what will be the output...i'm sure you will amazed to see the result

Re: [algogeeks] c doubt

2011-08-31 Thread Sanjay Rajpal
The result will depend on alignment : byte alignment or Word alignment. Sanju :) On Wed, Aug 31, 2011 at 2:51 AM, PRATEEK VERMA prateek...@gmail.com wrote: oh i'm sorry guys galz,its my mistake..actually i forgot to add one more field in struct this is the correct one typedef struct

Re: [algogeeks] c doubt

2011-08-31 Thread kartik sachan
@ prateek i am still not geeting why now out put is 4 but if we change second bit2:5 then out put again 8 plzz explain throughly -- 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.

Re: [algogeeks] c doubt

2011-08-31 Thread Kunal Patil
@kartik: typedef struct { int bit1:29; int bit2:4; }bit; This makes total number of bits 33, which is not on int boundry. (multiple of 32 bits) So to make it aligned on int boundry, 31 extra bits are padded at the end of bit2. This makes size of struct 29 + 4 + 31 = 64 bits -- 8 bytes. When bit1

Re: [algogeeks] c doubt

2011-08-31 Thread annarao kataru
why it(total) should be a multiple of 32 bits..can u clarify it? -- 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

Re: [algogeeks] c doubt

2011-08-31 Thread kartik sachan
becoz int is of 4btyes so 32 bits required -- 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.

Re: [algogeeks] c doubt

2011-08-30 Thread PRATEEK VERMA
@kartik it's wrong output...output will be 8 bytes.I asked this question just to give more clear picture of bit field -- 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

Re: [algogeeks] c doubt

2011-08-30 Thread Kamakshii Aggarwal
@prateek:can u pls explain y the o/p will be 8??according to me also o/p should be 4. On Tue, Aug 30, 2011 at 11:42 PM, PRATEEK VERMA prateek...@gmail.comwrote: @kartik it's wrong output...output will be 8 bytes.I asked this question just to give more clear picture of bit field -- You

Re: [algogeeks] c doubt

2011-08-30 Thread kartik sachan
@prateek check this i have complied on ideone http://ideone.com/UV7MG output is 4 only -- 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

Re: [algogeeks] c doubt

2011-08-29 Thread manish patel
it will be 00. Bit fields are allocated within an integer from least-significant to most-significant bit. In the following code struct mybitfields { unsigned short a : 4; unsigned short b : 5; unsigned short c : 7; } test; int main( void ); { test.a = 2; test.b = 31;

[algogeeks] c doubt

2011-08-28 Thread ravi maggon
class{ int bit1:1; } please explain the meaning of line 2. -- Regards Ravi Maggon -- 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

Re: [algogeeks] c doubt

2011-08-28 Thread PRATEEK VERMA
int bit1:1; above definition instructs compiler that use 1 bit for storing integer(signed by default) in bit1. Such notation is used for optimization of memory use. So if someone stores 1 in bit1 then,it will be treated as -1 by compiler since we have instructed the compiler to store it in one

[algogeeks] C doubt

2011-08-28 Thread rohit
Why does the following code not give an error? #includestdio.h void fun(char *a) //array decays to pointer here { a[0] = 'a'; printf(%s\n,a); } int main() { char p[]=hello; fun(p); getch(); } if i write something like this in main char *arr=hello arr[0] = 'r';

Re: [algogeeks] C doubt

2011-08-28 Thread himanshu kansal
cz when u do char p[]=hello compiler automatically allocates enough memory(6 charc here) and puts your string there.. but whn u do char*a=hello then its complr dependent where d string will be storedsome compiler stores it in a special location in data segmnt whch is (read only )so

Re: [algogeeks] C doubt

2011-08-28 Thread rohit
Thanks for your reply himanshu, ...I am aware of the above stated fact but my doubt is that when i pass this char array to a function and accept it as a char pointer (char *a), and then when write a[0] = 'a', why don't i get an error? -- You received this message because you are subscribed to

Re: [algogeeks] C doubt

2011-08-28 Thread Apoorve Mohan
@rohit: why do you think this should give error??? On Sun, Aug 28, 2011 at 5:17 PM, rohit raman.u...@gmail.com wrote: Thanks for your reply himanshu, ...I am aware of the above stated fact but my doubt is that when i pass this char array to a function and accept it as a char pointer (char

Re: [algogeeks] C doubt

2011-08-28 Thread himanshu kansal
because when u pass an array, the address of memory location that is recievd in the func is accessible and write allowed also to u..so u dont get an error On Sun, Aug 28, 2011 at 5:17 PM, rohit raman.u...@gmail.com wrote: Thanks for your reply himanshu, ...I am aware of the above stated

Re: [algogeeks] C doubt

2011-08-28 Thread rahul vatsa
wen u pass an array as parameter to a func, it does decay to a pointer, nd compiler doesn't stop u to change contents of the array through this pointer. basically u can change or not the value at some memory location depends on how u have allocated it not how u r accessing it. On Sun, Aug 28,

Re: [algogeeks] c doubt

2011-08-28 Thread kartik sachan
@PRATEEK if i make int bit1:2 then it will store 2 bytes for example if bit1=4;then out will be 0 or 1 my question is it storing number from least significant bit or most significant bit??? suppose for 4 0100 so out will be 00 or 01?? -- You received this message because you are subscribed to

[algogeeks] C doubt

2011-08-23 Thread Arun Vishwanathan
say that you have a structure with some fields of known size and unknown size.For example, a char, an integer and an integer array.I do not know the size of the integer array until the user mentions the number of bytes he needs this integer array to cover in the command line as an argument.Is it

Re: [algogeeks] C doubt

2011-08-23 Thread Ankur Goel
u will be taking pointer in structure and use malloc to allocate memory for the number of integer u need On Wed, Aug 24, 2011 at 10:21 AM, Arun Vishwanathan aaron.nar...@gmail.comwrote: say that you have a structure with some fields of known size and unknown size.For example, a char, an

[algogeeks] C doubt

2011-08-11 Thread Algo Lover
Suppose i create a block of 10 ints, p is a pointer pointing to this block. int (*p)[10]; How can i initialize these 10 integer blocks using pointer p. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] C doubt

2011-08-11 Thread UTKARSH SRIVASTAV
#includestdio.h main() { int a[10],i; int (*p)[10]; p=a; for( i=0;i10;i++) { *((int *)p+i)=i; } for( i=0;i10;i++) { printf( %d,a[i]); } } -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT

[algogeeks] c doubt

2011-08-08 Thread Mohit Goel
#includestdio.h #includeconio.h struct abc { char p[1]; }; int main() { struct abc *c =NULL; char name[]=abcde; c = (struct abc *) malloc (sizeof(struct abc)); strcpy(c-p,name); printf(%s,c-p); getch(); return 0; } why it is printing the whole string

Re: [algogeeks] c doubt

2011-08-08 Thread Debabrata Das
this is a case of heap corruption On Mon, Aug 8, 2011 at 10:40 PM, Mohit Goel mohitgoel291...@gmail.com wrote: #includestdio.h #includeconio.h struct abc {    char p[1]; }; int main() {     struct abc *c =NULL; char name[]=abcde; c = (struct abc *) malloc (sizeof(struct

Re: [algogeeks] c doubt

2011-08-08 Thread Debabrata Das
when you do maloc or new , space is allocated from heap segment of your process address space. Though you have alllocated (sizeof(struct abc) space but strcpy copies abcde beyond your allocated space and overwrite the contents, we should avoid this scenario and use strncpy so that it cannot go

[algogeeks] C++ doubt

2011-08-04 Thread Shachindra A C
Hi All, In the code below, even though pD is actually pointing to a base class object, how is the print function being successfully called? #includeiostream class base { public: int BVal; base() { BVal = 100; } }; class derived : public base { public:

[algogeeks] C doubt

2011-07-31 Thread Tyler Durden
How do we declare an array of N pointers to functions that return int?? An array of N pointers to integers is this: int *p[N] Just can't figure out the case for pointers to function -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view

[algogeeks] C doubt!

2011-07-25 Thread Nitish Garg
This following code produces output as 8 4 4. 8 is fine, as the size of an int plus a pointer is 8, but why the size of p and q is being shown as 4? #includestdio.h#includestdlib.hint main(){ struct node { int data; struct node * link; }; struct

Re: [algogeeks] C doubt!

2011-07-25 Thread aditi garg
u hv answered ur ques in ur ques itself...:) c u understand size of struct node as 4+4=8 rite?? now in this 4 is size of int and 4 is the size of the pointer of the type struct node... now wat are p and q? dey are also pointers to struct node jst like link...now whn u understand dat the size of

Re: [algogeeks] C doubt!

2011-07-25 Thread Neeraj Gupta
On Tue, Jul 26, 2011 at 1:43 AM, Nitish Garg nitishgarg1...@gmail.comwrote: This following code produces output as 8 4 4. 8 is fine, as the size of an int plus a pointer is 8, but why the size of p and q is being shown as 4? #includestdio.h#includestdlib.hint main(){ struct node

Re: [algogeeks] C doubt!

2011-07-25 Thread Nitish Garg
My bad! Thanks. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/kiSipxeFkwAJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe

Re: [algogeeks] c doubt

2011-07-14 Thread sangeeta goyal
thnx all...i got it :) On Thu, Jul 14, 2011 at 2:13 AM, Anika Jain anika.jai...@gmail.com wrote: As in base 10 we say 552.5 is same as 5.525 *10^2 , here 2 is the exponent of base 10.. so similarly in binary nos. for base 2 here if i make 101.00110011.. to 1.0100110011.. *2^2 my exponent

Re: [algogeeks] c doubt

2011-07-13 Thread Anika Jain
binary equivalent of 5.2 is 101.0011001100110011001100110011(nonterminating).. now it is actually stored in normalised frorm in 32 bits.. like this --1 bit for sign8 bits for exponent-23 bits for fraction-- this is from higher order byte to lower order for little endian..

Re: [algogeeks] c doubt

2011-07-13 Thread Piyush Kapoor
Shouldn't the value of 1100 be -64 On Wed, Jul 13, 2011 at 4:53 PM, Anika Jain anika.jai...@gmail.com wrote: binary equivalent of 5.2 is 101.0011001100110011001100110011(nonterminating).. now it is actually stored in normalised frorm in 32 bits.. like this --1 bit for sign8

Re: [algogeeks] c doubt

2011-07-13 Thread Anika Jain
sorry its 0100 not 1100 coz 5.2 is a positive no. so sign bit is 0 On Wed, Jul 13, 2011 at 7:58 PM, Piyush Kapoor pkjee2...@gmail.com wrote: Shouldn't the value of 1100 be -64 On Wed, Jul 13, 2011 at 4:53 PM, Anika Jain anika.jai...@gmail.comwrote: binary equivalent of 5.2

Re: [algogeeks] c doubt

2011-07-13 Thread Piyush Kapoor
why is the order of numbers reversed? On Wed, Jul 13, 2011 at 8:07 PM, Anika Jain anika.jai...@gmail.com wrote: sorry its 0100 not 1100 coz 5.2 is a positive no. so sign bit is 0 On Wed, Jul 13, 2011 at 7:58 PM, Piyush Kapoor pkjee2...@gmail.comwrote: Shouldn't the value of

Re: [algogeeks] c doubt

2011-07-13 Thread Anika Jain
it is not unsigned its signed but positive thts y it is 0.. the order isnt reversed.. look at the code, the code 1st prints lowest order byte then next and then next and then highest soo output is 102 102 -90 64 On Wed, Jul 13, 2011 at 8:08 PM, Piyush Kapoor pkjee2...@gmail.com wrote: why is

Re: [algogeeks] c doubt

2011-07-13 Thread sunny agrawal
I think it is machine dependent and current output is for a little endian machine and output should be reverse for a big endian machine On Wed, Jul 13, 2011 at 10:18 PM, Anika Jain anika.jai...@gmail.com wrote: it is not unsigned its signed but positive thts y it is 0.. the order isnt

Re: [algogeeks] c doubt

2011-07-13 Thread Anika Jain
ya thts ryt, for big endian it will be 64 -90 102 102 On Wed, Jul 13, 2011 at 10:22 PM, sunny agrawal sunny816.i...@gmail.comwrote: I think it is machine dependent and current output is for a little endian machine and output should be reverse for a big endian machine On Wed, Jul 13, 2011 at

Re: [algogeeks] c doubt

2011-07-13 Thread Piyush Kapoor
Will u guyz pls tell me frm where do u study terms like endian ,it is a pity i had to google it :( :( On Wed, Jul 13, 2011 at 10:30 PM, Anika Jain anika.jai...@gmail.com wrote: ya thts ryt, for big endian it will be 64 -90 102 102 On Wed, Jul 13, 2011 at 10:22 PM, sunny agrawal

Re: [algogeeks] c doubt

2011-07-13 Thread Sunny T
computer organization carl hamacher. computer system architecture by Morris Mano. Computer organization and architecture by william stallings.. if u dont have these refer wikipedia. On Wed, Jul 13, 2011 at 10:59 PM, Piyush Kapoor pkjee2...@gmail.com wrote: Will u guyz pls tell me frm where do u

Re: [algogeeks] c doubt

2011-07-13 Thread Piyush Kapoor
thanks,i hv just entered 2nd year,so most probably i will study this year -- *Regards,* *Piyush Kapoor,* *CSE-IT-BHU* -- 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

Re: [algogeeks] c doubt

2011-07-13 Thread Kamakshii Aggarwal
@anika:can u please explain the meaning of this line.. so i here get an exponent of 2 as 2 here.. now in exponent 8 bits this exponent is stored as 127+exponent so here it becomes 1001.. On Wed, Jul 13, 2011 at 11:44 PM, Piyush Kapoor pkjee2...@gmail.com wrote: thanks,i hv just entered 2nd

Re: [algogeeks] c doubt

2011-07-13 Thread Anika Jain
As in base 10 we say 552.5 is same as 5.525 *10^2 , here 2 is the exponent of base 10.. so similarly in binary nos. for base 2 here if i make 101.00110011.. to 1.0100110011.. *2^2 my exponent is 2.. now in storage of floats exponent is stored as exponent +127 i.e here 2 +127 so we get 1001

[algogeeks] c doubt

2011-07-11 Thread geek forgeek
#includestdio.h main(){int a=10,b; a=5?b=10:b=20;printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(%d\n,b);} y this is asking for lvalue while this(below) not? #includestdio.h main(){int a=10,b; a=5?b=10:(b=20);printf

Re: [algogeeks] c doubt

2011-07-11 Thread aditya pratap
this is something like this thats why it is giving lvalue required. u r going to store the the value over value which is not a variable at left hand side. main(){int a=10,b; (a=5?b=10:b)=20;printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(%d\n,b);} On Mon, Jul 11, 2011

Re: [algogeeks] c doubt

2011-07-11 Thread vaibhav shukla
remember in C , the false statement cannot be used for assignment, if u write it without braces.It is allowed in C++ but not in C In C compiler would treat it as what aditya has explained.hence the error. On Mon, Jul 11, 2011 at 12:59 PM, aditya pratap contacttoadity...@gmail.com wrote: this

Re: [algogeeks] c doubt

2011-07-11 Thread nicks
@vaibhav.i don't think there is any rule like you mentioned.if it is plz mention it's source i think the explanation by aditya is correct it's just due to the precedence order which is = ?: = in descending order hence first = is evaluated then ?: followed by =...due to which lvalue

Re: [algogeeks] c doubt

2011-07-11 Thread Piyush Kapoor
Can anybody give a full explanation On Sat, Jul 9, 2011 at 10:49 PM, sunny agrawal sunny816.i...@gmail.comwrote: try to find out the binary representation of float value 5.2 On Sat, Jul 9, 2011 at 10:46 PM, Sangeeta sangeeta15...@gmail.com wrote: int main(){ int i; float a=5.2; char

Re: [algogeeks] c doubt

2011-07-11 Thread Sandeep Jain
Sunny is right. Try to observe the binary representation, and you shall get your answers. Regards, Sandeep Jain On Mon, Jul 11, 2011 at 5:54 PM, Piyush Kapoor pkjee2...@gmail.com wrote: Can anybody give a full explanation On Sat, Jul 9, 2011 at 10:49 PM, sunny agrawal

Re: [algogeeks] c doubt

2011-07-11 Thread oppilas .
On Mon, Jul 11, 2011 at 5:54 PM, Piyush Kapoor pkjee2...@gmail.com wrote: Can anybody give a full explanation http://ideone.com/K1QmV On Sat, Jul 9, 2011 at 10:49 PM, sunny agrawal sunny816.i...@gmail.comwrote: try to find out the binary representation of float value 5.2 On Sat, Jul 9,

[algogeeks] c++ doubt

2011-07-10 Thread himanshu kansal
class a { int x; public: a() { } a(int i){x=i;coutin a xendl;} a(a obj){coutin copy cons of aendl;} }; a obj1=14; //error no matching call to a::a(a) why. and just adding a const in the constructor saves me from error...but how --

Re: [algogeeks] c++ doubt

2011-07-10 Thread rahul
use a(int arg) { x = arg; } ur call will work...:) On Sun, Jul 10, 2011 at 11:46 PM, himanshu kansal himanshukansal...@gmail.com wrote: class a { int x; public: a() { } a(int i){x=i;coutin a xendl;} a(a obj){coutin copy cons of aendl;}

Re: [algogeeks] c++ doubt

2011-07-10 Thread rahul
my badadd const in copy construcori think...that compiler expect... On Sun, Jul 10, 2011 at 11:48 PM, rahul rahulr...@gmail.com wrote: use a(int arg) { x = arg; } ur call will work...:) On Sun, Jul 10, 2011 at 11:46 PM, himanshu kansal himanshukansal...@gmail.com wrote:

Re: [algogeeks] c++ doubt

2011-07-10 Thread himanshu kansal
a obj3(obj1);but this statement works fine.so it means it is calling copy constt. perfectly... On Sun, Jul 10, 2011 at 11:49 PM, rahul rahulr...@gmail.com wrote: my badadd const in copy construcori think...that compiler expect... On Sun, Jul 10, 2011 at 11:48 PM, rahul

Re: [algogeeks] c++ doubt

2011-07-10 Thread Sandeep Jain
The reason is... that when u write a obj1=14; it is same as writing a obj1 = a(14); So first a temporary object is created using the constructor a(int i) And this temporary object is passed in the copy constructor. BUT since it is temp object it must be referred by a const alias. Regards,

Re: [algogeeks] c++ doubt

2011-07-10 Thread himanshu kansal
thanku sir...sir 1 more thngcn u gv a link or some pdf for studying virtual inheritance elaborating the vptr mechanism more clearly... On Sun, Jul 10, 2011 at 11:56 PM, Sandeep Jain sandeep6...@gmail.comwrote: The reason is... that when u write a obj1=14; it is same as writing a obj1 =

Re: [algogeeks] c++ doubt

2011-07-10 Thread Sandeep Jain
http://www.parashift.com/c++-faq-lite/virtual-functions.html Its one of my favorite sites... :) Regards, Sandeep Jain On Mon, Jul 11, 2011 at 12:02 AM, himanshu kansal himanshukansal...@gmail.com wrote: thanku sir...sir 1 more thngcn u gv a link or some pdf for studying virtual

[algogeeks] c doubt

2011-07-09 Thread Sangeeta
int main(){ int i; float a=5.2; char *ptr; ptr=(char *)a; for(i=0;i=3;i++) printf(%d ,*ptr++); } output: 102 102 -90 64.explain? -- 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.

Re: [algogeeks] c doubt

2011-07-09 Thread sunny agrawal
try to find out the binary representation of float value 5.2 On Sat, Jul 9, 2011 at 10:46 PM, Sangeeta sangeeta15...@gmail.com wrote: int main(){ int i; float a=5.2; char *ptr; ptr=(char *)a; for(i=0;i=3;i++) printf(%d ,*ptr++); } output: 102 102 -90 64.explain? -- You received

[algogeeks] c doubt

2011-07-04 Thread Sangeeta
#Iincludestdio.h #includestring.h main() { char str[]=S\061AB; printf(\n%d,strlen(str)); } output:4 why? -- 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

Re: [algogeeks] c doubt

2011-07-04 Thread Vishal Thanki
because \061 is considered as a single char in ur string.. On Mon, Jul 4, 2011 at 12:52 PM, Sangeeta sangeeta15...@gmail.com wrote: #Iincludestdio.h #includestring.h main() { char str[]=S\061AB; printf(\n%d,strlen(str)); } output:4 why? -- You received this message because you are

Re: [algogeeks] c doubt

2011-07-04 Thread sameer.mut...@gmail.com
Continuous memory allocation is used for 2-d array. So a[2][5] will assign 10 continuous memory spaces. Hello will be stored on the 1st 5 spaces. Hi will be saved on the next 2 consecutive spaces itself. There is no null character saved for the 1st string so while printing it prints until it finds

Re: [algogeeks] c doubt

2011-07-04 Thread Sandeep Jain
If you try to visualize the internal representation. You've allocated 10 bytes. | h | e | l | l | o | | h | i |\0 |\0 |\0 | Since these are stored in linear form, so the actual representation would be | h | e | l | l | o | h | i |\0 |\0 |\0 | Now a[0] points to 'h' in the first row, and printf

Re: [algogeeks] c doubt

2011-07-04 Thread sangeeta goyal
thanx i got it :) On Mon, Jul 4, 2011 at 2:05 PM, Sandeep Jain sandeep6...@gmail.com wrote: If you try to visualize the internal representation. You've allocated 10 bytes. | h | e | l | l | o | | h | i |\0 |\0 |\0 | Since these are stored in linear form, so the actual representation would

Re: [algogeeks] c doubt

2011-06-24 Thread Anika Jain
ya i got it.. thanx On Thu, Jun 23, 2011 at 6:01 PM, rajeev bharshetty rajeevr...@gmail.comwrote: It is because of the ! operator in front of a , !a is always 0(in case a is value other than 0) so it takes it as integer and hence the size is 4 bytes whereas only a you will get 12 . The !

[algogeeks] c doubt

2011-06-23 Thread Anika Jain
int main() { long double a; signed char b; printf(%d\n,sizeof(!a+b)); return 0; } why is it 4?? shouldnt it be 12 as per sizeof long double in gccc -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] c doubt

2011-06-23 Thread prathimzn
i thing that if u negate any value by ! the result will be always a int.. so !a will be a integer value and !a+b due to typecast will be also int.. you can verified this fact by seeing the result of sizeof (!a+a) = 12 sizeof (!b) =4 sizeof (!a) =4 sizeof(!(a+b)) =4

Re: [algogeeks] c doubt

2011-06-23 Thread piyush kapoor
int main() { char a; printf(%d %d,sizeof(a),sizeof('a')); return 0; } Output: 1 4 why does the expression sizeof('a') evaluates it as an integer,not as a character?? -- *Regards,* *Piyush Kapoor,* *CSE-IT-BHU* -- You received this message because you are subscribed to the Google

Re: [algogeeks] c doubt

2011-06-23 Thread rajeev bharshetty
@piyush Because of its interpretation as ascii .The character's ascii value is taken into account which is an integer . On Thu, Jun 23, 2011 at 6:32 PM, piyush kapoor pkjee2...@gmail.com wrote: int main() { char a; printf(%d %d,sizeof(a),sizeof('a')); return 0; } Output: 1 4

Re: [algogeeks] c doubt

2011-06-23 Thread piyush kapoor
You didn't understand my question... Why is sizeof() interpreting a constant character literal as ascii??? -- *Regards,* *Piyush Kapoor,* *CSE-IT-BHU* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] c doubt again

2011-06-23 Thread Anika Jain
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

Re: [algogeeks] c doubt again

2011-06-23 Thread Piyush Sinha
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

Re: [algogeeks] c doubt again

2011-06-23 Thread Anika Jain
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

Re: [algogeeks] c doubt again

2011-06-23 Thread Piyush Sinha
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,

Re: [algogeeks] c doubt again

2011-06-23 Thread harshit pahuja
@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

Re: [algogeeks] c doubt again

2011-06-23 Thread Anika Jain
i mean how it working actually? On Thu, Jun 23, 2011 at 8:06 PM, Anika Jain anika.jai...@gmail.com wrote: hey ya its working :) but whats the logic behind it?? On Thu, Jun 23, 2011 at 7:52 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: sorry by mistake i added it in scanf situation..

Re: [algogeeks] c doubt again

2011-06-23 Thread Piyush Sinha
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

Re: [algogeeks] c doubt

2011-06-23 Thread rajeev bharshetty
In C, the type of a character constant like 'a' is actually an int, with size of 4. In C++, the type is char, with size of 1. This is one of many small differences between the two languages. On Thu, Jun 23, 2011 at 6:50 PM, piyush kapoor pkjee2...@gmail.com wrote: You didn't understand my

Re: [algogeeks] c doubt again

2011-06-23 Thread rajeev bharshetty
@ 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

Re: [algogeeks] c doubt again

2011-06-23 Thread harshit pahuja
@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

Re: [algogeeks] c doubt again

2011-06-23 Thread Piyush Sinha
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

Re: [algogeeks] c doubt

2011-06-23 Thread piyush kapoor
Thanks a lot :) -- *Regards,* *Piyush Kapoor,* *CSE-IT-BHU* -- 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

Re: [algogeeks] c doubt

2011-06-23 Thread Apoorve Mohan
@anika: the negation operation returns 0 or 1 which is an integerso u get this output On Thu, Jun 23, 2011 at 10:29 PM, piyush kapoor pkjee2...@gmail.com wrote: Thanks a lot :) -- *Regards,* *Piyush Kapoor,* *CSE-IT-BHU* -- You received this message because you are subscribed

Re: [algogeeks] c doubt again

2011-06-23 Thread Anika Jain
@ 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

Re: [algogeeks] c doubt again

2011-06-23 Thread harshit pahuja
@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

Re: [algogeeks] c doubt

2011-06-23 Thread rajeev bharshetty
It is because of the ! operator in front of a , !a is always 0(in case a is value other than 0) so it takes it as integer and hence the size is 4 bytes whereas only a you will get 12 . The ! changes the data type here . Hope it clears the doubt :) -

[algogeeks] C doubt

2011-06-05 Thread amit
Suppose I want to copy an integer array to another array pointed by a void pointer of different size. Some thing like this is done probably in realloc function. The problem is it is not working for me ... here's the code #include stdio.h int main(){ int *p,i=0; void *x;

Re: [algogeeks] C doubt

2011-06-05 Thread Piyush Sinha
@Amit Jaspal...there is a fundamental error in the code related to pointersu have incremented the pointers p and x..so before the printf loop, pointer p (as well as x) is pointing to 4th location...I hope I am clear... this can be done by creating two more pointers that will initialised as

Re: [algogeeks] C doubt

2011-06-05 Thread Vishal Thanki
Usually it is a bad practice to increment the pointer. Rather, one should use the indexing variable to dereference the pointer at some index. One more bug in your code was, you are allocating the space for only 3 ints for p and storing 4 ints. Here is the code with some modification. #include

Re: [algogeeks] C doubt

2011-06-05 Thread hary rathor
are bhai just you use memcpy function in string.h you need worry about any ... is it sufficient ? -- 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

[algogeeks] c doubt

2011-02-12 Thread snehal jain
does the check x==x+1 always return false for integer x? -- 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

Re: [algogeeks] c doubt

2011-02-12 Thread Rashmi Gupta
yaeh its correct it always return the false statement according to the operator rules On Sat, Feb 12, 2011 at 6:16 AM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: according to me,it always return false.. On Sat, Feb 12, 2011 at 5:24 PM, snehal jain learner@gmail.comwrote: does the

[algogeeks] C++ Doubt

2011-01-20 Thread Decipher
When we can convert Derived* to Base* then why can't we convert Derived** to Base** ?? -- 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

  1   2   >