shruti


{ City } pune
< Country > india
* Profession * sap - technical consultant
User No # 13969
Total Questions Posted # 0
Total Answers Posted # 68

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 1350
Users Marked my Answers as Wrong # 556
Questions / { shruti }
Questions Answers Category Views Company eMail




Answers / { shruti }

Question { Deltech, 79962 }

WHAT IS THE DIFFERENCE BETWEEN malloc() and calloc() in c
file management?


Answer

malloc will only allocate space in the memory..

calloc will allocate space in the memory as well as
initialise it to a particular value.

Is This Answer Correct ?    134 Yes 39 No

Question { 11761 }

Why doesn't the code "int a = 1000, b = 1000;
long int c = a * b;" work?


Answer

i think, the result exceeds the long int value..

the result is 10 and 6 0s..

and it exceeds the value for the long in

long int is 4 bytes..
the highest value is 65524 (m not very sure.. this could be
one of the reasons)..

Is This Answer Correct ?    0 Yes 2 No


Question { 13920 }

What's wrong with "char *p; *p = malloc(10);"?


Answer

the syntax of malloc is wrong.

in your example it should be written as:

char *p;

p = (char *)malloc(sizeof(char));

Is This Answer Correct ?    21 Yes 1 No

Question { Satyam, 7801 }

what is meant by the "equivalence of pointers and arrays" in
C?


Answer

An array is a constant pointer.
a[10] is equivalent to *a..
it is known as base pointer..

Is This Answer Correct ?    0 Yes 3 No

Question { IBM, 11881 }

How do I declare a pointer to an array?


Answer

you do not need to declare a pointer to any array..

an array itself is a constant pointer..

a[10] is equivalent to *a.

Is This Answer Correct ?    15 Yes 4 No

Question { 11557 }

How can I set an array's size at run time?


Answer

that is the main drawback of an array..
u cannot assign memory at run time...

Is This Answer Correct ?    2 Yes 5 No

Question { Aloha Technology, 7522 }

When you call malloc() to allocate memory for a local
pointer, do you have to explicitly free() it?


Answer

yup.. we have to explicitly free it..
otherwise it results in "dangling pointer"..

Is This Answer Correct ?    20 Yes 0 No

Question { Geometric Software, 13220 }

difference between my-strcpy and strcpy ?


Answer

yes there is nothing like my-strcpy..

i think u must have come accross some prog. in which a user
must have written a func. for string copy and named it as
my-strcpy...

strcppy is an in-built function for string copy.
the function body is present in string.h.

Is This Answer Correct ?    5 Yes 2 No

Question { Cisco, 37232 }

which of the function operator cannot be over loaded

a) <=
b)?:
c)==
d)*


Answer

In C we do not have the operator overloading concept.

Is This Answer Correct ?    7 Yes 8 No

Question { Verifone, 27862 }

int a=1,b=2,c=3;
printf("%d,%d",a,b,c);
What is the output?


Answer

Compilation error..

no. of arguments do not match the parameters..

Is This Answer Correct ?    8 Yes 15 No

Question { Hughes, 17225 }

f(char *p)
{
p=(char *)malloc(sizeof(6));
strcpy(p,"HELLO");
}
main()
{
char *p="BYE";
f(p)
printf("%s",p);
}
what is the output?


Answer

The output would be "HELLO"..

though we are not returning the string, we are making
direct changes at the memory location..

so "bye" will be overwritten with "HELLO"


because we are using pointers, the dying pointer scenario
is not applicabe here..

Its a pointer, not a variable..


This function will work similar to -> swapping two numbers
using pointers..
juss check that prog if you fnd somewhere.. :-)
you will get the logic... :-)


Cheers...


--By the way a gud ques.. :-)

Is This Answer Correct ?    1 Yes 4 No

Question { IBM, 11589 }

What will be the result of the following program?
main()
{
char p[]="String";
int x=0;

if(p=="String")
{
printf("Pass 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
else
{
printf("Fail 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
}

a) Pass 1, Pass 2
b) Fail 1, Fail 2
c) Pass 1, Fail 2
d) Fail 1, Pass 2
e) syntax error during compilation


Answer

syntax error during compilation..


we cannot compare strings using if(p == "string")

so will not work..

NOTE:
while comparing string otherwise also we use 'string'
(string in single quotes ' ' not " ")..

Is This Answer Correct ?    0 Yes 2 No

Question { Mascot, 8598 }

Switch (i)
i=1;
case 1
i++;
case 2
++i;
break;
case 3
--i;
Output of i after executing the program


Answer

WHAT IS THE VALUE OF I BEFORE ENTERING THE SWITCH CASE???

if the values is something other than 1 , 2 , 3 there wont
be any effect, ASSUMING u have forgotton to give the curly
braces.


otherwise,
you will get an error, if the curly braces are not there
for the switch case.

Is This Answer Correct ?    7 Yes 0 No

Question { Motorola, 18065 }

Tell about strtok & strstr functions


Answer

The above answer is perfect...

Kudos..
well done..

Is This Answer Correct ?    3 Yes 1 No

Question { Wipro, 11582 }

n=7623
{
temp=n/10;
result=temp*10+ result;
n=n/10
}


Answer

the answer depends upon, to what value result is
initialised..

Is This Answer Correct ?    6 Yes 2 No

 [1]   2   3   4   5    Next