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
the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....
What are the advantages and disadvantages of a heap?
What does sizeof return c?
How can you increase the allowable number of simultaneously open files?
What are the types of variables in c?
What is file in c language?
which type of aspect you want from the student.
What is a protocol in c?
What is string concatenation in c?
Who is the main contributor in designing the c language after dennis ritchie?
Explain what is the stack?
The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference
What are the disadvantages of external storage class?
What's the total generic pointer type?
An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode