Question

Create an array size 10 and fill it with integers from 1 to 10. Print out...

Create an array size 10 and fill it with integers from 1 to 10. Print out the values.
Then, create a pointer that points to the beginning of the array. Finally, print out all the values through a pointer and the memory address where the value is. With C

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>
int main()
{
int arr[10]= {1,2,3,4,5,4,6,8,9,10};//array of size 10 create and filled with integers 1 to 10
  
for(int i=0;i<10;i++)
printf("\n%d",arr[i]);// printing the elements of the array
  
printf("\n");
  
int *p=&arr[0];//pointer pointing to the first element of the array
  

for(int i=0; i<10; i++)
printf("\n%d ",*(p+i));//printing the elements with the help of pointer
  
printf("\n");
  
for(int i=0; i<10; i++)
printf("\n%u ",(p+i));//printing the memory addresses of the values using pointer
return 0;
}

Add a comment
Know the answer?
Add Answer to:
Create an array size 10 and fill it with integers from 1 to 10. Print out...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java: Create an array of Integers with 10 elements, loop (use a for loop) through...

    In Java: Create an array of Integers with 10 elements, loop (use a for loop) through the array of integers printing their values to the screen. Create an array of Strings with 10 elements, loop (use a for loop) through the array of Strings printing their values to the screen. Finally, create an ArrayList of Integers. Use the loop from part 1 above and add each integer as you print it to the ArrayList as well, then start a final...

  • Create a function that takes two parameters : pointer to the array and the size of...

    Create a function that takes two parameters : pointer to the array and the size of the array. Print out the array's values and their memory addresses inside the function. Then create another function that takes two parameters : pointer to the array. Inside the function, multiply each of the array's values by two ad print the modified values out in the main function. With C programming language

  • Create a class with an array of type integer of size 15. Fill the array with...

    Create a class with an array of type integer of size 15. Fill the array with random integers of size 1 to 1000. Sort the array. Print out the contents of the array. Thank you in advance

  • Create 3 variables, (int, chart and float) and give give each of them some value. Print...

    Create 3 variables, (int, chart and float) and give give each of them some value. Print out the values. Then create a pointer for each variable and initialize the pointers. Then make them point to the memory address of the corresponding variables. Print out the pointers (=memory addresses where the pointers point to, use %p). Finally, print out the values that are in the memory locations where the pointers point to(so print out the values using the pointers, not the...

  • need question 3 assap using cin and cout outputs please Ctrl CSC 270 Final Exam-Spring2 1) [10 pts] Create anarray x which includes integers fron ltos obtain the array y which, even formula. Displ...

    need question 3 assap using cin and cout outputs please Ctrl CSC 270 Final Exam-Spring2 1) [10 pts] Create anarray x which includes integers fron ltos obtain the array y which, even formula. Display both arrays x and y in a table with labeled column headings. 0 y- 2x+1 2) 120 pts] Consider the following 2D array. 01 2 -1 X-3 5 0 6 -3 7 -15 Use the standard notation and obtain the following (a) Create and display array...

  • Create an array of size 10 Assign values to the array Print the array Swap the...

    Create an array of size 10 Assign values to the array Print the array Swap the first and last elements in the array Print the array Shift all elements by one to the right Print the array Replace even elements with 0 Replace each element except the first and last by the larger of its two neighbors Print the array

  • Create a C project named login_l03t1. Create an array of int from parameters passed on the...

    Create a C project named login_l03t1. Create an array of int from parameters passed on the command line. Use argc to define the size of the array. Print the contents of the array in the format and Generate and print the total of the values in the array twice: once by using an index i, and a second time by incrementing a pointer to the array. I need help with this please! what I have done is below: int n...

  • in java / You will: // 1- create a square 2 dimensional array of random size...

    in java / You will: // 1- create a square 2 dimensional array of random size (less than 11) // 2- fill the array with random integers from 1 to the size limit // 3- print the array // 4- prompt to see if the user wants to do another //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // 1- The square can use the same random value for x and y. Don't allow 0 size arrays. // 2- Maybe a nested set of for loops? to...

  • Create a C program that: Within main, declares a linear array consisting of 10 double values....

    Create a C program that: Within main, declares a linear array consisting of 10 double values. You can assign values to the array when it is declared or fill them items manually using scanf () - your choice. Also, declare three doubles: min, max, and average. Then from within main, a function is called. The function should take a pointer to the array declared above and then finds the maximum value, the minimum value, and calculates the average of the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT