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 l

[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 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

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 wrote: > i have a file 'star.txt' containing

[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 the

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-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 algogeeks+unsubs

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 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 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 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 > { > int bit1:

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 a

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-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 wrote: > @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 messag

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 unsubscr

Re: [algogeeks] c doubt

2011-08-29 Thread kartik sachan
@prateek obivously we are calculating size of struct so its output is 4 (if u consider int as 4 bytes) what is the relation between this and above question?? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email

Re: [algogeeks] c doubt

2011-08-28 Thread PRATEEK VERMA
@kartik there is nothing to do as how computer stores the datasome may be little endian or big endian. only thing that matters here is how the bits are being accessed. computer accesses the bits from left to right. you can ensure by running the following code main() { int r=456; int *p; p=&

Re: [algogeeks] c doubt

2011-08-28 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; test

Re: [algogeeks] C doubt

2011-08-28 Thread kartik sachan
u r changing readonly memory that's why segment error -- 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...@google

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 th

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, 201

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 wrote: > Thanks for your reply himanshu, ...I am aware of the above stated fact but > my doubt

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 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 *a), and then when wr

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 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 mod

[algogeeks] C doubt

2011-08-28 Thread rohit
Why does the following code not give an error? #include 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'; //this

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 bit

[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 e

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 wrote: > say that you have a structure with some fields of known size and unknown > size.For example, a char, an integer and an integer arra

[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 po

Re: [algogeeks] C doubt

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

[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 alg

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 be

Re: [algogeeks] c doubt

2011-08-08 Thread Mohit Goel
@debabratas: can u plz explain this term ..heap corruption .. -- 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+unsubsc

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 wrote: > #include > #include > struct abc > { >    char p[1]; > }; > int main() > { >     struct abc *c =NULL; > char name[]="abcde"; > c = (struct abc *) malloc (sizeof(struct abc)); > > strcpy(c->p,

[algogeeks] c doubt

2011-08-08 Thread Mohit Goel
#include #include 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 "abcde"..t

[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? #include class base { public: int BVal; base() { BVal = 100; } }; class derived : public base { public: derived()

[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 th

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 unsubscrib

Re: [algogeeks] C doubt!

2011-07-25 Thread Neeraj Gupta
On Tue, Jul 26, 2011 at 1:43 AM, Nitish Garg wrote: > 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? > > #include#includeint main(){ > struct node > { >int data; >

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 lin

[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? #include#includeint main(){ struct node { int data; struct node * link; }; struct node *p, *q; p

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 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 is 2.. now in storage

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 On

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 wrote: > thanks,i hv just entered 2nd year,so most proba

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 uns

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 wrote: > Will u guyz pls tell me frm where do u study terms like "

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 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 > wrote: > >> I think it is

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 wrote: > 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 Ja

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 wrote: > it is not unsigned its signed but positive thts y it is 0.. > the order isnt reversed.. look at the code,

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 wrote: > why is the order of numbers

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 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 wrote: > >> Shouldn't the value of "1100" be -64 >> >> >> On Wed, Jul

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 wrote: > Shouldn't the value of "1100" be -64 > > > On Wed, Jul 13, 2011 at 4:53 PM, Anika Jain wrote: > >> binary equivalent of 5.2 is >> 101.00110011001100110011001

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 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 sign---><-8 bits for ex

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 sign---><-8 bits for exponent-><23 bits for fraction--> this is from higher order byte to lower order for little endi

Re: [algogeeks] c doubt

2011-07-13 Thread Piyush Kapoor
why do we need a NthIntWithKBits() in this topic? On Tue, Jul 12, 2011 at 7:58 AM, oppilas . wrote: > > > On Mon, Jul 11, 2011 at 5:54 PM, Piyush Kapoor wrote: > >> Can anybody give a full explanation >> >> http://ideone.com/K1QmV > >> On Sat, Jul 9, 2011 at 10:49 PM, sunny agrawal >> wrote: >>

Re: [algogeeks] c doubt

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

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 wrote: > Can anybody give a full explanation > > > On Sat, Jul 9, 2011 at 10:49 PM, sunny agrawal wrote: > >> try to find out the bin

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 wrote: > try to find out the binary representation of float value 5.2 > > > On Sat, Jul 9, 2011 at 10:46 PM, Sangeeta wrote: > >> int main(){ >> int i; >> float a=5.2; >> char *ptr; >> ptr=(char *)&a; >> for(i=0;

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 err

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 wrote: > this is something like this thats

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 ("%d\n",b);} On Mon, Jul 11,

[algogeeks] c doubt

2011-07-11 Thread geek forgeek
#include main(){int a=10,b; a>=5?b=10:b=20;printf ("%d\n",b);} y this is asking for lvalue while this(below) not? #include main(){int a=10,b; a>=5?b=10:(b=20);printf

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 inh

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 wrote: > The reason is... that when u write > a obj1=14; > it is same as writing a obj1 = a(14); > So first a

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, Sandee

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 wrote: > my badadd const in copy construcori think...that compiler expect... > > > On Sun, Jul 10, 2011 at 11:48 PM, rahul wrote: > >> use a(int

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 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: > >> clas

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;cout<<"in a "

[algogeeks] c++ doubt

2011-07-10 Thread himanshu kansal
class a { int x; public: a() { } a(int i){x=i;cout<<"in a "

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 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 this mes

[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

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 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 > be > | h | e |

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 s

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 sameer.mut...@gmail.com
The meaning of 0 is being escaped, it now represents Octal and the following digits are taken to be an octal number. Ascii equivalent of the octal no. is being taken as a character. Ascii equivalent of octal no. 61 is 1. So it takes it to be 4 characters.. S,1,A,B Another example would be.. #incl

[algogeeks] c doubt

2011-07-04 Thread Sangeeta
#include #include void main() { char a[2][5]= { "hellodear", "hi"}; printf("%s%s",a[0],a[1]); } output:hellohi hi explain? -- 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-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 wrote: > #Iinclude > #include > main() > { > char str[]="S\061AB"; > printf("\n%d",strlen(str)); > } > output:4 > why? > > -- > You received this message because you are subscribed to the Google

[algogeeks] c doubt

2011-07-04 Thread Sangeeta
#Iinclude #include 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 group, sen

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 wrote: > 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

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 :) - Rajee

Re: [algogeeks] c doubt again

2011-06-23 Thread harshit pahuja
@anika -thankx :) On Thu, Jun 23, 2011 at 11:57 AM, Anika Jain 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 wrote: > >> or u cud consult

Re: [algogeeks] c doubt again

2011-06-23 Thread Anika Jain
@ piyush : oh thanx.. i understood it :) On Thu, Jun 23, 2011 at 11:57 AM, Anika Jain 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 wrote: > >

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 wrote: > or u cud consult ANSI C by Balaguruswamy in chapter of Console I/Ps and > O/Ps > > On 6/23/11, harshit pa

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 wrote: > Thanks a lot :) > > > -- > *Regards,* > *Piyush Kapoor,* > *CSE-IT-BHU* > > -- > You received this message because you are subscribed to the Goo

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 algogeeks+unsubscr..

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 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 bharshett

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 wrote: > @ Piyush Could u provide the link to some source , because i am still > unclear about the above concept . > > R

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 wrote: > there is no as such logic behind it..its just the format specifier... > > u must be knowing printf returns the numbe

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 wrote: > You didn't understand my question... > Why is siz

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 again

2011-06-23 Thread Anika Jain
i mean how it working actually? On Thu, Jun 23, 2011 at 8:06 PM, Anika Jain wrote: > hey ya its working :) but whats the logic behind it?? > > > On Thu, Jun 23, 2011 at 7:52 PM, Piyush Sinha wrote: > >> sorry by mistake i added it in scanf situation.. >> actually this type of specifier can be us

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 wrote: > sorry by mistake i added it in scanf situation.. > actually this type of specifier c

Re: [algogeeks] c doubt again

2011-06-23 Thread Anika Jain
hey ya its working :) but whats the logic behind it?? On Thu, Jun 23, 2011 at 7:52 PM, Piyush Sinha 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() > {

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/2

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 wrote: > 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

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 find

[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 algogeeks@

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 al

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 wrote: > int main() > { > char a; > printf("%d %d",sizeof(a),sizeof('a')); > return 0; > } > Output: > 1 4 > > why do

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 G

  1   2   >