array contains zeros and ones as elements.we need to bring
zeros one side and one other side in single parse.
ex:a[]={0,0,1,0,1,1,0,0}
o/p={0,0,0,0,0,1,1,1}
Answer Posted / vignesh1988i
good morning sir,
in ur above program , u said u took then length as 8 and
then allocated ur memory using DMA... but ur way of
allocation find to be wrong sir.... as you allocated
int *ptr=(int*)malloc(sizeof(8));
the above statement will allocate only 2 bytes for u....
since you have given 8 inside sizeof operator.. this will
tell the compiler allocate 2 bytes of memory .. ur
instruction must be :
int *ptr=(int*)malloc(8*sizeof(int));
so, then it will allocate 8*2 bytes of memory sir.....
so only in my program i have given n*sizeof(int) , where
'n' can be any value that user gives........
thank u
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
Is malloc memset faster than calloc?
Explain how can I prevent another program from modifying part of a file that I am modifying?
.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }
What is dynamic memory allocation?
What is void main () in c?
Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.
a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list
Why do we write return 0 in c?
How old is c programming language?
What is cohesion and coupling in c?
Explain About fork()?
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
What is nested structure with example?
What are the types of type specifiers?
What does a derived class inherit from a base class a) Only the Public members of the base class b) Only the Protected members of the base class c) Both the Public and the Protected members of the base class d) .c file