Thursday, July 30, 2009

C programmers help me please?

want help in a C program


in which i have to display tables of numbers upto the no which user enter





but imust use all of these following


1)pointer


2)function


3)recurtion

C programmers help me please?
ok a function is just a way to divide up the code to do something for you. A pointer points to an address in memory where something is stored, and recursion is a process in which an algorithm is repeated.





Ex:





int NumberArray[100]; //makes an array to store up to 100 integers


int HowLarge; //variable for how many numbers are to be in the array





int *GetNumbers() {


cout%26lt;%26lt;"How many numbers are you going to input?"%26lt;%26lt;endl;


cout%26lt;%26lt;"Choice: ";cin%26gt;%26gt;HowLarge;


for(int i=0 ; i%26lt;HowLarge ; i++) { //the recursion part, it gets user input to add any numbers in the array


cout%26lt;%26lt;"Input Number "%26lt;%26lt;i+1;cin%26gt;%26gt;NumbersArray[i];


}


}


//ok pretty easy, gets numbers and puts them in an array.





void ShowArray(int *Array) { //now we will show the array


for(int i=0 ; i%26lt;sizeof(Array)/4 ; i++) { //cycles through the array


cout%26lt;%26lt;"Number "%26lt;%26lt;i+1%26lt;%26lt;" of the Array is: "%26lt;%26lt;Array[i]%26lt;%26lt;endl;


}


}





that should do it. If you have any questions about the code look at the refrence below.
Reply:instead of asking people to do your work for you, post a code sample of what you have done already. that way you learn what you did right and what you did wrong. Having someone write a program for you is a waste.
Reply:I agree with thunder.... if you show me I can help you, I may be a young girl ( roughly 17) but I got the answers. ^_^ so show me the money!


No comments:

Post a Comment