Question

Write a program using C in Microsoft visual studios. Write a function that receives an array...

Write a program using C in Microsoft visual studios.

Write a function that receives an array of integers and the array length and prints one integer per line (Hint: Use \n for a line break). Left align all of the integers and use a field width of 10. Populate an array of 10 elements from the user and pass the array and its length to the function.

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

#include <stdio.h>

void printArray(int array[10],int length) //function

{

int i;

printf("\nElements of array : \n");

for(i=0;i<length;i++)

{

printf("<%-10d>\n",array[i]); //< > to display width , - sign with field for left justified

}

}

int main(void) {

int array[10],length,i;

length = 10;

printf("\nEnter the elements of array : ");

for(i=0;i<length;i++)

scanf("%d",&array[i]);

printArray(array,length); //call to function printArray

return 0;

}

Output:

Add a comment
Know the answer?
Add Answer to:
Write a program using C in Microsoft visual studios. Write a function that receives an array...
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
  • Can someone help me with this problem. We're using microsoft visual studios and its from my...

    Can someone help me with this problem. We're using microsoft visual studios and its from my assembly code language class. we're using this template in class from the lecture slides Write a program and verify it using visual studio that does the following: Use type, lengthof, and size to make your program more independent of the data type. 3) Write a program that first reads the message entered by the user and stores it in Myname. Then it prints the...

  • Must be done in C++ 2013 microsoft visual studio Write a program that creates a 4...

    Must be done in C++ 2013 microsoft visual studio Write a program that creates a 4 x 5 two-dimensional array. The program should use loops to populate the array using the rand, srand and time functions with random numbers between 10 and 60. After the values have populated the array, output the values of the array to the screen in something that looks like a 4 x 5 table.

  • C# Visual Studios HelloWorld For this assignment, you'll work with first creating an array and populating...

    C# Visual Studios HelloWorld For this assignment, you'll work with first creating an array and populating it's values. Then, we'll use the values in the array to calculate the average. Since it's common for an average to result in numbers with decimal points, the array you create should be of type double[]. This program will need to use dynamic input from the user so perform the following steps: Ask the user how many numbers need to be added. Use this...

  • Include the blackbox output done with C# microsoft visual studios software. write a C# program to...

    Include the blackbox output done with C# microsoft visual studios software. write a C# program to sort a parallel array that consists of customer names and customer phone numbers. The solution should be in ascending order of customer names. For instance, if the input is string[] custNames- { "ccc", "ddd", "aaa", "bbb" }; stringl] custIds687-3333", "456-4444", "789-1111", "234-2222" ; then, the solution is string[] string[] custNames- { "aaa", "bbb", "ccc", "ddd" }; custIds"789-1111", "234-2222", "687-3333", "456-4444"]; There are some restrictions:...

  • Write a C Program that inputs an array of integers from the user along-with the length...

    Write a C Program that inputs an array of integers from the user along-with the length of array. The program then prints out the array of integers in reverse. (You do not need to change (re-assign) the elements in the array, only print the array in reverse.) The program uses a function call with array passed as call by reference. Part of the Program has been given here. You need to complete the Program by writing the function. #include<stdio.h> void...

  • (C++) Write a function, remove, that takes three parameters: an array of integers, the number of...

    (C++) Write a function, remove, that takes three parameters: an array of integers, the number of elements in the array, and an integer (say, removeItem). The function should find and delete the first occurrence of removeItem in the array. (Note that after deleting the element, the number of elements in the array is reduced by 1.) Assume that the array is unsorted. Also, write a program to test the function. Your program should prompt the user to enter 10 digits...

  • P3 - An Array of objects (120 points) Write a main program and declare an array...

    P3 - An Array of objects (120 points) Write a main program and declare an array of 5 RectangularCube objects [20pts). a. Use a loop to initialize an array of RectangularCube. In the body of the loop use the rand () function to generate random integers between 1 and 10 to assign to length, width and height data fields of each RectangularCube object (40pts) b. Write the function with header void printCube (RectangularCube rs) that receives an object of the...

  • create a file homework_part_1.c a) Implement the function initialize_array that receives two parameters: an array of...

    create a file homework_part_1.c a) Implement the function initialize_array that receives two parameters: an array of integers and the array size. Use a for loop and an if statement to put 0s in the odd positions of the array and 5s in the even positions. You must use pointers to work with the array. Hint: review pointers as parameters. b) Implement the function print_array that receives as parameters an array of integers and the array size. Use a for statements...

  • In C only Please! This lab is to write a program that will sort an array...

    In C only Please! This lab is to write a program that will sort an array of structs. Use the functions.h header file with your program. Create a source file named functions.c with the following: A sorting function named sortArray. It takes an array of MyStruct's and the length of that array. It returns nothing. You can use any of the sorting algorithms, you would like though it is recommended that you use bubble sort, insertion sort, or selection sort...

  • Write a C program to do the following: 1. Write a C function named find that...

    Write a C program to do the following: 1. Write a C function named find that receives a one-dimensional array of type character named arr and its size of type integer. After that, the function must select a random index from the array. The function must find if the character stored in the randomly selected index comes before all the characters to its left alphabetically. Finally, the function prints to the screen the element if the element meets the condition...

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
ADVERTISEMENT