Displaying an array by using pointer techniques [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to display the contents of an array with type double that has a length of 5 without using the [ ] indexing . I can only use a for loop and pointer techniques.
How can you achieve that ?
Can anyone give me a brief explanation of pointers as I have no idea how to use them exactly ?

The array indexing operator is a shorthand for hiding pointer arithmetic.
So if you have an array like this:
double a[5];
Instead of using this expression:
a[1]
You can use this:
*(a + 1)

Related

How to create an example for the complex statement? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
There is a complex statement in my textbook:
int (*f(float (*)(long),char *))(double);
I want to create an example for illustrating how to use this statement, although I understand the meaning of the statement, it's hard for me to write the example. Can anyone help me?
P.S.: C language.
int (*f(float (*)(long),char *))(double)
f is a function that has 2 parameters of type
float (*)(long), << pointer to function long=>float
char * << string
and returns
(int)(*)(double) << a pointer to a function double=>int

For Loops in C to print out individual ints. [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to print out each integer of an int individually using a for loop. I am doing this because I want to print things in between some of the single ints. So if the number was 4564, I want to print out 4 5 6 4. Is there a quick way to do this?
I know how to do it in java but I am new to C and am not sure.
Something like this shall help
while(num!=0) {
printf("%d", num%10); //your last digit, you can store it in an array of characters as well
num = num/10 ;
}
Note : you've got to reverse the order while using the digits

Dynamic string splitting to get the last word [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a challenge question like "What is your favorite movie?". There could be any question like this. I need last word of the question i.e. movie. without question mark.
Try this
String question = "What is your favorite movie";
String lastWord = question .substring(question .lastIndexOf(" ")+1);
When you select the element containing your challenge question, you can call .getText() (in Java; similar in other languages) to get the text inside. Then, you can use regular expressions or substring utilities in your language to strip out the last word.

How to combine increment and decrement statements into one single statements [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
How can i combine one increment and one decrement statements into one single statement in C language.
ex: a++ and b-- into one single statement.
Write a++,b--;
Two expressions separated by a comma are evaluated left to right.

C programming: logarithmic index array [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm trying to decimate a given vector with a logarithmic rule instead of a linear one.
e.g.:
The given vector has 100 elements. I want to reduce it to a vector of 10 elements that are the same elements of the starting vector taken with a logarithmic rule on the int interval [0,99].
I hope to be clear enough. Any help is appreciated !
Have a nice day !
In pseudo-code :
int n; // Length of subsampled array
for i:
new_array[i] = array[(int)(log(i)/log(n)*length(array))]
Is that what you are trying to do ?

Resources