in pointers
can we use for loop in the function or
we should use the recursion with it
in pointers
can we use for loop in the function or
we should use the recursion with it
show me the meaning
You can use for loops to increment/decrement pointers and such, for arrays or whatever. What are you asking?
Away.
heh, what do u mean????
so far, I can give you some hints, where you can find something about pointers:
www.cprogramming.com (the tutorials)
http://cboard.cprogramming.com/showt...threadid=41754
and search the board
i find the answer
i was mean that
if we writing a function
in pointers
can we use for loop inside
the function or we should use only (if -else)
show me the meaning
yeah, why not????
I don't know, what you wanna do, so you have to decide, whether it's better or worse for your prog....
Write a function addElement that takes as parameters: a pointer to a sorted array of integer numbers, array size (number of elements stored in the array), and the number to be inserted in the array. The function should insert the element in the proper position to keep the list sorted. Use pointer operations to access the elements of the array. The function prototype is
void addElement(intt *array, int *sizeptr, int num);
#include <stdio.h>
#define size 10
void addelement(int*,int *,int );
int main()
{
int i,array[10],s,num;
printf ("enter the size\n");
scanf("%d",&s);
printf("enter the array:\n");
for(i=0;i<=s;i++)
scanf("%d",&array[s]);
printf("add a number to the array\n");
addelement(array, &s, num);
return 0;
}
void addelement(int*array,int *sizeptr,int num)
{
int i;
for(i=0; i >=sizeptr ; i++)
printf ("add number");
printf("%d\n%d ",array[size],num);
}
}
show me the meaning
i do this program but i cant find the error
Write a function addElement that takes as parameters: a pointer to a sorted array of integer numbers, array size (number of elements stored in the array), and the number to be inserted in the array. The function should insert the element in the proper position to keep the list sorted. Use pointer operations to access the elements of the array. The function prototype is
void addElement(intt *array, int *sizeptr, int num);
#include <stdio.h>
#define size 10
void addelement(int*,int *,int );
int main()
{
int i,array[10],s,num;
printf ("enter the size\n");
scanf("%d",&s);
printf("enter the array:\n");
for(i=0;i<=s;i++)
scanf("%d",&array[s]);
printf("add a number to the array\n");
addelement(array, &s, num);
return 0;
}
void addelement(int*array,int *sizeptr,int num)
{
int i;
for(i=0; i >=sizeptr ; i++)
printf ("add number");
printf("%d\n%d ",array[size],num);
}
}
thanx
show me the meaning
It think, this is correct now:
heh, solved ya problem againCode:#include <stdio.h> #define size 10 void addelement(int*,int *,int ); int main() { int i,array[10],s,num; printf ("enter the size\n"); scanf("%d",&s); printf("enter the array:\n"); for(i=0;i<=s;i++) scanf("%d",&array[s]); printf("add a number to the array\n"); addelement(array, &s, num); return 0; } void addelement(int*array,int *sizeptr,int num) { int i; for(i=0; i >=*sizeptr ; i++) printf ("add number"); printf("%d\n%d ",array[size],num); }
I haven't had compiled it.... I found 2 mistakes.
[edit]
Plz check it, whether it compiles and runs corrently and whether it does, what you want it to do for you
[/edit]
Last edited by codingmaster; 07-12-2003 at 01:23 PM.
the program run
but
in the end
it doesnt
type the number i add
it gives
the position
of num
show me the meaning
Originally posted by itcs
the program run
but
in the end
it doesnt
type the number i add
it gives
the position
of num
Burma Shave!
Sorry, couldn't resist
Definition: Politics -- Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers
still not run
as i want
can u
write
all the
program
plz
may be i didnt understand u
show me the meaning
Most of it has been written for you already. try piecing it all together, and then askng specific questions when you need help.Originally posted by itcs
still not run
as i want
can u
write
all the
program
plz
may be i didnt understand u
[edit]
Doh, beat!
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
u help me sooooooooooo
much all of u
I promise to post it on tuseday
because i think
i can answer it now
see u then
thank salem &mastercode
show me the meaning
i didnt mean 2 heart u r feeling
coodingmaster