this ques has been answered be4 on this grp...and u missed the macro
definition as welljst a few days bak...search the group
On Wed, Aug 10, 2011 at 11:00 PM, rohit rajuljain...@gmail.com wrote:
main()
{
int m,n;
m=3+max(2,3);
n=2*max(3,2);
printf(“%d,%d”,m,n);
}
ans:-m=2,n=3
why
can someone explain the output of following program?
#includestdio.h
main(){char *p=hai friends,*p1;
p1=p;while(*p!='\0') ++*p++;printf(%s,p1);}
i got run time error in gcc..
--
radhika .. :)
--
You received this message because you are subscribed to the Google Groups
Algorithm
++*p++
This statement changing the value of read only memory of string constant
*p=hai friends ;
--
*With Regards :*
Ravinder Kumar
B.Tech Final Year
Computer Science and Engineering
MNNIT Allahabad
--
You received this message because you are subscribed to the Google Groups
Algorithm
thks ravinder.. !
char p[]=hi
char *p = hi
are both string constants?
On Wed, Aug 3, 2011 at 2:08 AM, Ravinder Kumar ravinde...@gmail.com wrote:
++*p++
This statement changing the value of read only memory of string constant
*p=hai friends ;
--
*With Regards :*
Ravinder Kumar
hi is string constant in both cases... However using p[] allocates memory
and copies the string hi in it.
On Aug 3, 2011 2:17 AM, Radhika Renganathan radi.coo...@gmail.com wrote:
thks ravinder.. !
char p[]=hi
char *p = hi
are both string constants?
On Wed, Aug 3, 2011 at 2:08 AM, Ravinder
more specifically,,
char *p1 = in data;
char p2[] = in stack;
*p1 points to a string literal in process' data area. p2[] is allocated in
the current stack and then the string is copied into it as Jain correctly
stated,,
this data area is actually part of the process,,, it's allocated a
Please help me...
How can the following output be obtained :
1.main()
{
int i=1;
printf(%d\t%d\t%d\t,i,i++,i);
}
output: 2 1 2
2.main()
{
int i=1;
printf(%d\t%d\t%d\t,i,++i,i);
}
output: 2 2 2
3.main()
{
int i=1;
printf(%d\t%d\t%d\t,i,i++,i++);
}
output: 3 2 1
thanks
Regards
by THANU
-
--
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
I cant understand the third one
On Mon, Aug 1, 2011 at 6:09 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:
printf scans the arguments from right to left for any arithmetic operations
to be performed. If found, they are evaluated according to their precedence.
In 1. main()
{
int i=1;
3.main()
{
int i=1;
printf(%d\t%d\t%d\t,i,i++,i++);
}
output: 3 2 1
Scan from right. Rightmost i++ is encountered. Value of i is incremented
but this is post increment, so the effect of increment will not show on this
i (But other i's are now incremented). Again another i++ is
Niks u r wrng..this is undefined. Different results in different compilers
--
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/-/es-F94sx2KIJ.
To post to this
So which one to consider
On Mon, Aug 1, 2011 at 7:17 PM, Raman raman.u...@gmail.com wrote:
Niks u r wrng..this is undefined. Different results in different compilers
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion
Nikhil only explained third rightly. :-/
I think 1,2,4's output are given wrong by thanu.
On Mon, Aug 1, 2011 at 8:39 PM, muruga vel murugavidya1...@gmail.comwrote:
So which one to consider
On Mon, Aug 1, 2011 at 7:17 PM, Raman raman.u...@gmail.com wrote:
Niks u r wrng..this is undefined.
Please explain the output, that why is it in that form in hexadecimal form
#includestdio.h
int main()
{
printf(%d %x,-11,-11);
return 0;
}
output :
-2 fffe
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
this is bec -1 in hexadecimal is
On Fri, Jul 29, 2011 at 11:37 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:
Please explain the output, that why is it in that form in hexadecimal form
#includestdio.h
int main()
{
printf(%d %x,-11,-11);
return 0;
}
output :
-2
I couldn't understand the problem .. u have used %x as indentifier that why
it is so
On Fri, Jul 29, 2011 at 11:37 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:
Please explain the output, that why is it in that form in hexadecimal form
#includestdio.h
int main()
{
printf(%d
i figured it out. I didnt know before that is was in 2's complement form .
On Fri, Jul 29, 2011 at 11:53 PM, sukhmeet singh sukhmeet2...@gmail.comwrote:
I couldn't understand the problem .. u have used %x as indentifier that why
it is so
On Fri, Jul 29, 2011 at 11:37 PM, Ankur Khurana
fffe is two's complement of 2.
Let me explain for fe and you can extrapolate it with other f's.
f =15, e =14. fe = 1110, ~fe = 0001, ~fe+1 = 0010 = 2 which
gives your answer.
Thanks Regards,
Prashant Bhutani
Senior Undergraduate
Computer Science Engineering (B.Tech)
Institute of
#include‹stdio.h›
main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}
ouput: compiler error.
Any logical reasons?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
well im not sure bt i guess one possible reason could be that struct yy is a
member of struct xx..so a pointer of struct yy cannot be declared widout ref
to xx...
On Wed, Jul 27, 2011 at 9:52 PM, Aman Goyal aman.goya...@gmail.com wrote:
#include‹stdio.h›
main()
{
struct xx
{
int x;
struct
Well, this is quiet obvious even the least follower of C struct can answer
it but the good part is why does compiler is design to do so..
Hope ppls do follow me in this activation rec..
yy *q
struct yy (defined in somewhere)
x..
Guys above notation is in stack so srry again for no
if i declare a string constant inside another function
like let us say
,
int how()
{
char *s=hello;
return s;
}
so when how() get executed , the memory for hello will remain reserved or it
can be allocated to others. Will it amount to memory leak ?
--
Ankur Khurana
Computer Science
Netaji
a is a pointer to somewhere where string is written..
p is a pointer to somewhere where new sring is written.
temp is made to point at same location to which a is currently pointing that
is at string
by malloc some new memory is alloted and a is made to point to thast
memory.. temp remains to
#includeiostream
#includestring.h
using namespace std;
#define N(e) e#e
int main()
{
int i=1,j=2,k=3;
int m = i++ || j++ k++;
couti j k m;
}
output :-2 2 3 1
http://www.ideone.com/0sKBr
can anybody explain ? why are ++j and ++k are not evaluating even though
operator should be evaluated
Replace || by and then j and k will get evaluated.
The thing is that i think when the compiler sees a || operator ,if the
first operand is true than it wont check for the second.Thus j and k are not
getting evaluated.
On Tue, Jul 26, 2011 at 2:46 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:
This will be evaluated as i++ || (j++ k++) as gets the priority, so i
will get incremented to 2. As the left hand side of || is true, the result
is true and so the right hand side won't get evaluated.
--
You received this message because you are subscribed to the Google Groups
Algorithm
exactly what nithish has stated is the reason..as all the programming
languages uses short circuit method of evaluation for the relational
statements..as the right side expression of the 'or' is true..it
doesn't evaluate the left side expression, because now the left side
expression doesn't affect
but in precedence order || . Checked the same in dennis ricthie.
On Tue, Jul 26, 2011 at 2:53 PM, rajeev bharshetty rajeevr...@gmail.comwrote:
Replace || by and then j and k will get evaluated.
The thing is that i think when the compiler sees a || operator ,if the
first operand is true
On Tue, Jul 26, 2011 at 2:56 PM, Ankur Khurana ankur.kkhur...@gmail.com wrote:
but in precedence order || . Checked the same in dennis ricthie.
and || both have the same precedence.
There is a shorthand pattern of evaluation for the expressions.
learning that will help
Regards,
B.C.Someshwar
Dipankar, Thanks!!!
On Tue, Jul 26, 2011 at 8:44 AM, Dipankar Patro dip10c...@gmail.com wrote:
Swetha,
'\' in C is used to denote a escape sequence in C strings (and also in many
other languages).
e.g '\n' is for New Line '\n' is counted as one character.
Now '\ooo' is for an ASCII in
what will be the output fr this??
printf(ab\c);
On Tue, Jul 26, 2011 at 6:22 PM, swetha rahul swetharahu...@gmail.comwrote:
Dipankar, Thanks!!!
On Tue, Jul 26, 2011 at 8:44 AM, Dipankar Patro dip10c...@gmail.comwrote:
Swetha,
'\' in C is used to denote a escape sequence in C strings
op:abc.. \c is not an escape sequence
On Tue, Jul 26, 2011 at 10:17 PM, aditi garg aditi.garg.6...@gmail.comwrote:
what will be the output fr this??
printf(ab\c);
On Tue, Jul 26, 2011 at 6:22 PM, swetha rahul swetharahu...@gmail.comwrote:
Dipankar, Thanks!!!
On Tue, Jul 26, 2011 at
ya thats wat my doubt was...if its not a recognised escape sequence thn how
is it interpreted??
Would the compiler jst ignore ''\''?
On Tue, Jul 26, 2011 at 10:25 PM, Ram CEG honest...@gmail.com wrote:
op:abc.. \c is not an escape sequence
On Tue, Jul 26, 2011 at 10:17 PM, aditi garg
Yes compiler always ignores the first '\' and if it finds a recognizable
character after this escape sequence . it will interpret it. Otherwise it
just dumps it according to predefined semantics of machine code
generation.But I would suggest everyone in this group to try out
http://www.codepad.org
ya it would ignore \ alone..
On Tue, Jul 26, 2011 at 10:27 PM, aditi garg aditi.garg.6...@gmail.comwrote:
ya thats wat my doubt was...if its not a recognised escape sequence thn how
is it interpreted??
Would the compiler jst ignore ''\''?
On Tue, Jul 26, 2011 at 10:25 PM, Ram CEG
@Someshwar: precedence of ||
http://www.difranco.net/cop2220/op-prec.htm
--
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
main()
{
int i = 257;
int *iPtr = i;
printf(%d %d, *((char*)iPtr), *((char*)iPtr+1) );
}
can any one explain me the o/p ??
--
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
257 is stored as
B A
0001 0001
So iptr if int* will be pointing to this above
So if we typecast it as char* then it will point to 0001 (A)
and *ptr+1 will point to 0001(B)
Hope this clear .
On Mon, Jul 25, 2011 at
Will not it depend on whether the machine is big or little endian?
On Mon, Jul 25, 2011 at 11:50 AM, rajeev bharshetty rajeevr...@gmail.comwrote:
257 is stored as
B A
0001 0001
So iptr if int* will be pointing to this
Consider the binary representation of 257 which is 10001
which will be stored in little endain representation as least significant
eight bits + most significant eight bits as follows
0001 | 0001
now iptr on casting to char will point to least significant eight bits which
is 1, when
thnks all :)
@rajeev : u are right dats y *((char*)iPtr+2) will printf 0.
On Mon, Jul 25, 2011 at 11:56 AM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote:
Consider the binary representation of 257 which is 10001
which will be stored in little endain representation as least significant
eight
depends on endianess of processor
On Mon, Jul 25, 2011 at 12:22 PM, aditya kumar aditya.kumar130...@gmail.com
wrote:
thnks all :)
@rajeev : u are right dats y *((char*)iPtr+2) will printf 0.
On Mon, Jul 25, 2011 at 11:56 AM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote:
Consider the binary
@Rajeev : little endian and big endian could create difference in the
answers.
On Mon, Jul 25, 2011 at 11:50 AM, rajeev bharshetty rajeevr...@gmail.comwrote:
257 is stored as
B A
0001 0001
So iptr if int* will be
@Varun Ofcourse It Will !!! :)
On Mon, Jul 25, 2011 at 11:54 AM, varun pahwa varunpahwa2...@gmail.comwrote:
@Rajeev : little endian and big endian could create difference in the
answers.
On Mon, Jul 25, 2011 at 11:50 AM, rajeev bharshetty
rajeevr...@gmail.comwrote:
257 is stored as
I was refering to the answer on my system which Little endian ..
On Mon, Jul 25, 2011 at 5:11 PM, rajeev bharshetty rajeevr...@gmail.comwrote:
@Varun Ofcourse It Will !!! :)
On Mon, Jul 25, 2011 at 11:54 AM, varun pahwa varunpahwa2...@gmail.comwrote:
@Rajeev : little endian and big endian
Hi,
int main()
{
int a[5]={1,2,3,4,5};
int *ptr=a+1;
printf(%d,*(ptr-1));
}
It prints 5... Can somebody explain wats happening here..?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
a points to the address of the next array...i.e base address+20.ptr-1
points to the last element of array...so it is 5.
--
//BE COOL// kavi
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
here a is data type with 5*sizeof(int)
so a+1 will give u next address just after the alloted whole array
On Mon, Jul 25, 2011 at 7:44 PM, swetha rahul swetharahu...@gmail.comwrote:
Hi,
int main()
{
int a[5]={1,2,3,4,5};
int *ptr=a+1;
printf(%d,*(ptr-1));
}
It prints 5...
int main()
{
int a[5]={1,2,3,4,5};
int *ptr=a;
printf(%d,*(ptr));
getch();
}
Then why this prints 1.. ??
On Mon, Jul 25, 2011 at 7:50 PM, sagar pareek sagarpar...@gmail.com wrote:
here a is data type with 5*sizeof(int)
so a+1 will give u next address just after the alloted
On Mon, Jul 25, 2011 at 8:20 PM, swetha rahul swetharahu...@gmail.com wrote:
int main()
{
int a[5]={1,2,3,4,5};
int *ptr=a;
printf(%d,*(ptr));
getch();
}
Then why this prints 1.. ??
Here, ptr variable gets the starting address of the array 'a'. the
starting address by
Here a refers to the starting address of the array (or the base address)
So when you print *(ptr), it prints the value pointed to by ptr.
On Mon, Jul 25, 2011 at 8:20 PM, swetha rahul swetharahu...@gmail.comwrote:
int main()
{
int a[5]={1,2,3,4,5};
int *ptr=a;
printf(%d,*(ptr));
there's a lot diff b/w a and a+1.
try to figure out what type of pointer ptr is ?
yes its int* type
so during assignment a will assign address of a
and a+1 will give u address of sizeof(arr) * sizeof(int);
but actually ptr is still int* type..
i hope u get it...
On Mon, Jul 25, 2011 at 8:20 PM,
ptr points to base addr of a.And on base adrr of a is 1.Assume base addr of
a is 4000 then 1-4000,2-4002,3-4004,4-4006 and 5 on 4008 so op 1if in
question asking *(ptr+2) then op is 3.
Vijay..
On Mon, Jul 25, 2011 at 8:20 PM, swetha rahul swetharahu...@gmail.comwrote:
int main()
{
Thanks all... Got it!!!
On Mon, Jul 25, 2011 at 8:29 PM, Vijay Khandar vijaykhand...@gmail.comwrote:
ptr points to base addr of a.And on base adrr of a is 1.Assume base addr of
a is 4000 then 1-4000,2-4002,3-4004,4-4006 and 5 on 4008 so op 1if in
question asking *(ptr+2) then op is 3.
char *s=\12345s\n;
printf(\n %d,strlen(s));
The output is 5...?? But how.??
--
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
*void main()
*{*
int i;
char *a=String;
char *p=New String;
char *Temp;
Temp=a;
a=malloc(strlen(p) + 1);
strcpy(a,p);
p = malloc(strlen(Temp) + 1);
strcpy(p,Temp);
printf((%s, %s),a,p);
free(p);
free(a);
} *
*
*
*
*
*output is (New String,String)*
*
*
*how does Temp retains String even after New
Swetha,
'\' in C is used to denote a escape sequence in C strings (and also in many
other languages).
e.g '\n' is for New Line '\n' is counted as one character.
Now '\ooo' is for an ASCII in octal representation.
here is the list of all escape sequences:
@nicks- Dev-cpp supports gcc compilers only. Just saying
--
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/-/tpDu2bt_tG8J.
To post to this group, send email to
but its showing output
On Wed, Jul 20, 2011 at 6:53 PM, mohit verma mohit89m...@gmail.com wrote:
hey guys...
1. char c='a';
while(c=='a')
{
printf(%c,c);
c=getchar();
}
..
2.
char c='a';
while(c!='b')
{
printf(%c,c);
c=getchar();
}
@sourabh are you sure the code
int main()
{
g();
f();
}
inline int f(){
g();
return g()+1;
}
inline int g()
{
return 1;
}
does work i think i must give compilation error.
Because a function need to be declared, before it is called in case of c++.
and by inline the code in the function is
@varun
you are contradicting your own statement
when inline replaces the code at place where it is called, then this code
will work fine.
and the other one w/o inline won't as explained by others also.
there seems to be some confusion in your statement.
--
Tushar Bindal
Computer Engineering
#includestdio.h
#define FUN(arg) do\
{\
if(arg)\
printf(have fun...,\n);\
} while(i--)
void main()
{int i=2;
FUN(i3);
}
A.have fun..
have fun..
have fun..
B.have fun..have
the output will be (b)
before looking for the reason, you should know the syntax of printf
*int printf(const char *format,)*
the function at the string after the comma operator only if the format
string aks for any format specifier like %d or %f etc...u can try it like
this also in normal
Thanks a lot :)
On Mon, Jul 18, 2011 at 2:48 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
the output will be (b)
before looking for the reason, you should know the syntax of printf
*int printf(const char *format,)*
the function at the string after the comma operator only if the
for problem1 you can use %hi or %hd .. while scanning ..
On Thu, Jul 14, 2011 at 12:03 PM, Gaurav Jain gjainroor...@gmail.comwrote:
@Nicks
*Problem 1*
%d is used to take a signed integer as input. To take a short integer as
input, use %hi. That way, you would get the correct answer as 2.
@gaurav :y it is -2?y not +2?
On Sat, Jul 16, 2011 at 2:13 PM, sukhmeet singh sukhmeet2...@gmail.comwrote:
for problem1 you can use %hi or %hd .. while scanning ..
On Thu, Jul 14, 2011 at 12:03 PM, Gaurav Jain gjainroor...@gmail.comwrote:
@Nicks
*Problem 1*
%d is used to take a signed
value of b = 10 (in binary) and since b is a signed integer and also MSB is
1 so final value of b is 2's complement of 10 i.e. -2
On Sun, Jul 17, 2011 at 12:55 AM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:
@gaurav :y it is -2?y not +2?
On Sat, Jul 16, 2011 at 2:13 PM, sukhmeet singh
This should help you out.
http://msdn.microsoft.com/en-us/library/f90831hc.aspx
Regards,
Sandeep Jain
On Fri, Jul 15, 2011 at 11:15 AM, abhishek kumar
mailatabhishekgu...@gmail.com wrote:
@Sandeep Jain
sandeep, please be more clear about lvalue rvalue assignment.
--
You received
hi friends,
i have a doubt about this code. what will be its output and how.
int a=35,*b;
b=a;
++*b=++*b;
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
compilation error lvalue required
coz on lhs of ++*b=++*b is not a variable but a value
On Thu, Jul 14, 2011 at 11:58 AM, abhishek kumar
mailatabhishekgu...@gmail.com wrote:
hi friends,
i have a doubt about this code. what will be its output and how.
int a=35,*b;
b=a;
++*b=++*b;
--
@Nicks
*Problem 1*
%d is used to take a signed integer as input. To take a short integer as
input, use %hi. That way, you would get the correct answer as 2.
*Problem 2:*
a:1 means that variable a is of width *1 bit*
Similarly, b:2 means that b is of width *2 bits*
b = 6 sets the two bits as 10,
@sandeep
+1 for your answer of question 2 :)
On Tue, Jul 12, 2011 at 8:57 AM, Sandeep Jain sandeep6...@gmail.com wrote:
I'll put it in simple words, when printf is executed, it expects the
arguments to be of the same type and in the same order as they appear in the
format string.
Otherwise,
1st problem
format specifier is %d whereas memory is allocated only for short int
memory allocated-2bytes. but being stored in 4bytes.
so a is overwritten by b.
In dis case where u give a=1, b=1, a becomes become 0.
n so it gives:0+1=1
in d scanf if u use %hd instead u ll get d right output!!
@Nicks
*Problem 1*
%d is used to take a signed integer as input. To take a short integer as
input, use %hi. That way, you would get the correct answer as 2.
*Problem 2:*
a:1 means that variable a is of width *1 bit*
Similarly, b:2 means that b is of width *2 bits*
b = 6 sets the two bits as 10,
@nicks ---solving 295c questions .good dude..
On Thu, Jul 14, 2011 at 8:01 AM, nicks crazy.logic.k...@gmail.com wrote:
Hey Guys, plz help me in getting these 2 C output problems
*PROBLEM 1.*
*
*
*#*includestdio.h
int main()
{
short int a,b,c;
scanf(%d%d,a,b);
c=a+b;
@Anika
The code executes just all right.
@Abhishek
This is related to one of those irritating issues about precedence of
operators.
++ and * have the same precedence and have right-to-left associativity. So
your expression reads as
++(*b) = ++(*b)
RHS evaluates to 36 which gets stored in (*b)
then the version of spoj compiler for d must be belonging to an entirely
different world.I have solved a few problems using D and it had entirely
different syntax
On Thu, Jul 14, 2011 at 9:39 AM, shilpa gupta shilpagupta...@gmail.comwrote:
if you have any doubt than run it i have done
ignore anything i wrote above.I am an idiot anyway.
On Thu, Jul 14, 2011 at 2:42 PM, saurabh singh saurab...@gmail.com wrote:
then the version of spoj compiler for d must be belonging to an entirely
different world.I have solved a few problems using D and it had entirely
different syntax
@Abhi
Have a look at this.
http://codepad.org/zMV45iFY
On Thu, Jul 14, 2011 at 2:26 PM, Abhi abhi123khat...@gmail.com wrote:
@gaurav jain:
http://ideone.com/mRS9N
lvalue is required as LHS of assignment operator is a constant 'value'.
--
You received this message because you are
@ all
This code is error in C as pre-increment operator in C returns rvalue but it
will work fine in C++ as it returns lvalue in C++ which is required as LHS
of assignment operator
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this
Yup...
*In C++*
Pre-Increment Pre-Decrement return LValue
Post-Increment Post-Decrement return RValue
*In C*
Pre-Increment Pre-Decrement return RValue
Post-Increment Post-Decrement return RValue
Regards,
Sandeep Jain
On Thu, Jul 14, 2011 at 4:08 PM, T3rminal piyush@gmail.com wrote:
1)
getchar must be a function in that case . Check /usr/include/stdio.h . It
must have contained an extern definition (it is on my machine).
2)
Machines generally have separate registers for floating point values(let say
%fr). While executing this line *printf(%d\n,t); *that register is loaded
@Gaurav Jain
in turbo c++,(this was a c program).
it is giving output 36.
--
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/-/uuO64oNqACMJ.
To post to this
@ALL: Turbo C is one of the most pathetic compilers I've seen. It has
tremendous skills to ruin your concepts.
Regards,
Sandeep Jain
On Fri, Jul 15, 2011 at 10:35 AM, abhishek kumar
mailatabhishekgu...@gmail.com wrote:
@Gaurav Jain
in turbo c++,(this was a c program).
it is giving
@Gaurav Jain
but in Turbo C++ (as a c++ program)
it is giving output a=36.
--
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/-/ORNJxARkBIoJ.
To post to this
@Sandeep Jain
sandeep, please be more clear about lvalue rvalue assignment.
--
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/-/42bIvZNRPRYJ.
To post to this
For Problem 1, scanf tries to read 8 bytes from console (2 interger
due to %d) and it starts writing in memory from right to left. since
the variable are defined as short only two bytes will be stored.
bytes read by scanf
0 0 0 1 0 0 0 1
from right to left first 2 bytes that will be stored to b
in second problem a:1 and b:3 means default initialization but not in c it
is D programming language but u may b trying to compile it with c complier
that's why it is showing wrong result..if u will compile it with D
language compiler than it will print 6 and 2.and if u will not
There is nothing wrong going wrong in the code shilpa.
It specifies bit field
a has now only 1 bit
b has 2 bit.
when u write t.a=6=(0110) it is stored as 0.
while when u write t.b=2 it is stored as 10 which in 2's complement its -2.
check size of t if you doubt me.
On Thu, Jul 14, 2011 at 9:11
@saurabh why in 2's complement form ?
On Thu, Jul 14, 2011 at 9:21 AM, saurabh singh saurab...@gmail.com wrote:
There is nothing wrong going wrong in the code shilpa.
It specifies bit field
a has now only 1 bit
b has 2 bit.
when u write t.a=6=(0110) it is stored as 0.
while when u
For problem two the structure is bit field structure
a:1 means only one lower order bit will be stored
b:2 means only two lower order bits will be stored
since both are defined as int (signed)
t.b = 6 means 110, but 10 will be stored to b and being signed
interger its value become -2
t.b = 7
@saurabh .u r right it is correct but thing i have written is also
correct in D language it is initialization of elements of a structure
but the correct ans for this question will be yours..
On Thu, Jul 14, 2011 at 9:21 AM, saurabh singh saurab...@gmail.com wrote:
There is nothing
because your type is int (signed) and not unsigned..make it unsigned
you will understand why is like this!
On Thu, Jul 14, 2011 at 9:27 AM, John Hayes agressiveha...@gmail.com wrote:
@saurabh why in 2's complement form ?
On Thu, Jul 14, 2011 at 9:21 AM, saurabh singh saurab...@gmail.com
thnx all...i finally got it :)
On Thu, Jul 14, 2011 at 9:30 AM, sanjay ahuja sanjayahuja.i...@gmail.comwrote:
because your type is int (signed) and not unsigned..make it unsigned
you will understand why is like this!
On Thu, Jul 14, 2011 at 9:27 AM, John Hayes agressiveha...@gmail.com
By the way I am no master of D but isn't it compilation error?
D was made to imitate java concept of importing librariesSo its a
compile error anyway,:)
On Thu, Jul 14, 2011 at 9:30 AM, sanjay ahuja sanjayahuja.i...@gmail.comwrote:
because your type is int (signed) and not unsigned..make it
if you have any doubt than run it i have done so..it is running
On Thu, Jul 14, 2011 at 9:38 AM, saurabh singh saurab...@gmail.com wrote:
By the way I am no master of D but isn't it compilation error?
D was made to imitate java concept of importing librariesSo its a
compile error
Hey Guys, plz help me in getting these 2 C output problems
*PROBLEM 1.*
*
*
*#*includestdio.h
int main()
{
short int a,b,c;
scanf(%d%d,a,b);
c=a+b;
printf(%d,c);
return 0;
}
INPUT-
1 1
OUTPUT
1
i am not getting why 1 is coming in the output.what difference is using
short making in the code
Hey Guys, plz help me in getting these 2 C output problems
*PROBLEM 1.*
*
*
*#*includestdio.h
int main()
{
short int a,b,c;
scanf(%d%d,a,b);
c=a+b;
printf(%d,c);
return 0;
}
INPUT-
1 1
OUTPUT
1
i am not getting why 1 is coming in the output.what difference is using
short making in the code
Hey Guys, plz help me in getting these 2 C output problems
*PROBLEM 1.*
*
*
*#*includestdio.h
int main()
{
short int a,b,c;
scanf(%d%d,a,b);
c=a+b;
printf(%d,c);
return 0;
}
INPUT-
1 1
OUTPUT
1
i am not getting why 1 is coming in the output.what difference is using
short making in the code
On Tue, Jul 12, 2011 at 1:29 AM, nicks crazy.logic.k...@gmail.com wrote:
*PROBLEM 3.*
*
*
#includestdio.h
main()
{
enum {low='a',high='b'}tag;
char try=low;
printf(Size=%d,sizeof(tag));
switch (try)
{
case 'a':printf(aaa);break;
case 'b':printf(bbb);
case 'c':printf(ccc);
}
101 - 200 of 260 matches
Mail list logo