+ 5

I can't understand the 'function, arrays and pointers' of c Language. please help me.

I have learned the ' conditions and loops ' . But I can't understand the concepts of 'function, arrays and pointers' .

2nd Nov 2018, 12:12 PM
Roopesh
Roopesh - avatar
8 Réponses
+ 1
In C a function is like a SUB routine in BASIC. It is defined as ReturnType functionName( dataType variableName, ...) For example Int addnumbers(int a, int b) {return a+b);}; Will accept 2 integers and return an integer representing the result of adding those integers. Typically functions do more than this simple example, but this is a usable function. Arrays are groups of related items. For example an integer array of test scores would look like this Int arrayName[]={100,50,20,90,85}; The statement says create an array of integers and put the 5 numbers in the array. C programs require the first element index to be 0, and the indexes are numbered sequentially to the size of the array-1. To access members of the array use arrayName[indexNumber] the index number must be an int between 0 and the number of items in the array -1. In my example arrayName[0] will be 100 and the value of arrayName[4] will be 85. Once you have put information into an array you may alter print or use it in various ways.
4th Nov 2018, 5:58 AM
Roger Greenlaw
+ 7
When you've reached a point in your study where it's hard to proceed and a whole lot of things don't make sense anymore, this can be helpful: Stop with learning and write a few codes instead! Consciously try to apply everything you've learned so far; if something almost works, figure out how to make it actually work; do a few assignments that feel manageable. After a while, when you look at the formerly difficult chapters again, they may seem a lot easier.
3rd Nov 2018, 5:25 PM
HonFu
HonFu - avatar
+ 5
thanks
4th Nov 2018, 12:32 PM
Roopesh
Roopesh - avatar
+ 4
That's quite a bit of ground to cover. Please review the C course material and let us know if you have more specific questions.
2nd Nov 2018, 2:01 PM
Janning⭐
Janning⭐ - avatar
+ 2
Pointers are more difficult to understand because they can do many things. Simply thinking of a pointer as a reference to a variable's memory location stored in another variable. A good example is an array's name. The name is actually a pointer to the first item in the array. I hope these explanations help you. The others who have posted here are assuming you haven't tried the code in the C module. Go back to it in light of these definitions and examples and see if it makes any sense. If you are still experiencing problems ask more specific questions like "How do I know how many items are in an array. This way you will get answers which will be of more help to you.
4th Nov 2018, 6:07 AM
Roger Greenlaw
+ 1
your question scope is vast .Ask some specific questions so this will be easier to give answer .. you may also refer to this link for more information. https://www.tutorialspoint.com/cprogramming/c_functions.htm https://www.tutorialspoint.com/cprogramming/c_arrays.htm
2nd Nov 2018, 6:24 PM
Subham Subhasis Patra
Subham Subhasis Patra - avatar
13th Nov 2018, 5:50 PM
Freddy