void main()
{int a[5],i,b=16;
for(i=0;i<5;i++)
a[i]=2*i;
f(a,5,b);
for(i=0;i<5;i++)
printf("\n %d",a[i]);
printf("\n %d",b);
}
f(int *x,int n,int y)
{
int i;
for(i=0;i<n;i++)
*(x+i)+=2;
y=y+2;
}wat r the errors in the prg.and improvise the prg to get o/p.?
Answers were Sorted based on User's Feedback
Answer / vignesh1988i
so , i can understand at first you are inputting
implicitally the values in the array using the variable
used in for loops... then you are changing the values again
by writing the function... sending the base address of the
array.. then only once the y value will get added by 2...
as for as me their is no error in your program... so ur o/p
will be :
2
4
6
8
10
16
BUT IN ORDER TO MAKE OUT THE VALUE OF 'Y' TO BE
INCREMENTED FOR EACH VALUE IN THE LOOP AND TRY TO MAKE
CHANGE DIRECTLY IN THE ADDRESS , make these corrections
f(a,5,&b); , f(int *x,int n,int *y) , the for loop may be
like this :
for(i=0;i<n;i++)
{
(*(x+i))=(*(x+i))+2;
(*y)=(*y)+2;
}
after this ur o/p will be :
2
4
6
8
10
26
thank u
| Is This Answer Correct ? | 1 Yes | 0 No |
Is there any possibility to create customized header file with c programming language?
Write a program to compute the following 1!+2!+...n!
DIFFERNCE BETWEEN THE C++ AND C LANGUAGE?
How to write a program for swapping two strings without using 3rd variable and without using string functions.
What is the default value of local and global variables in c?
When is an interface "good"?
Explain how can I prevent another program from modifying part of a file that I am modifying?
To what value are pointers initialized? 1) NULL 2) Newly allocated memory 3) No action is taken by the compiler to initialize pointers.
Why c is a mother language?
write a program in c language to print your bio-data on the screen by using functions.
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
Tell us the difference between these two : #include"stdio.h" #include<stdio.h> define in detial.