STUDY GUIDE reading in numbers (integer and double) until a certain value/sentin
ID: 3830266 • Letter: S
Question
STUDY GUIDE
reading in numbers (integer and double) until a certain value/sentinel
functions
passing arrays
passing by pointers
MIN - see chapter 10 for some information
SEARCH
SORT
aligning output
comments
aligning code in source program
copying output to source program
This is the information I have on what my final program is going to be on. I was wondering does anone know if they can make a program for me out of this information. Or what the final program will be and help me code this thanks.
Explanation / Answer
Hi,
I can definitely help you in this.
1) Reading numbers - use scanf, or getline, or gets to get the number from standard input or the best option is to use argv array and pass the numbers as the command line.
2) function
a) Passing arrays - We can define a function which accepts the array. In C, the array are passed by their name as the name is the address of the first element. int a] = {1,2}; fun(a); void fun(int a[]);
b) Passing pointers - We can pass the address of variable to a function which accepts the address in terms of pointers. Ex : void fun(int *a) and this can be called as {int a; fun(&a) ;}
3) MIN - We can find the minimum number in the array by starting from the index and looping through all the elements and comparing with each other.
4) Search - searching requires looping of all the elements of the array and matching them with the element to be searched for all the index.
5) SORT - Sort can be ascending or descending. A function can accept 2 arguments with first one as array and second as sortasc or sortdesc. Then we can use bubble sort or quick sort for basic operations.
6) aligning output - Using printf, we can do this.
7) commenst - Both single line and multiline comments can be put before every function.
8) alining code in source program - use vim /emacs to remove the hard tabls with 4 spaces etc.
9) copying output to source program - yes use the "cp" command available usin fopen or system API call.
Let me know for more questions and help on the topic.
Thanks
Nikhil Jain
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.