answersLogoWhite

0


Best Answer

Reference:cprogramming-bd.com/c_page1.aspx# array programming

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a C Program to fill up an Integer Array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a c programme to draw a rainbow?

Write a C program to Draw a RAINBOW and fill the suitable colors ...


Write a program to declare 10 variables randomly and fill the array evenly using c plus plus?

#include<iostream> #include<chrono> #include<random> #include<vector> int main() { std::vector<int> Array; unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); std::default_random_engine generator (seed); std::uniform_real_distribution<int> distribution (0,100); for (size_t index=0; index<10; ++index) Array.push_back (distribution (generator)); }


Write a program that randomly fills a 10 component array then prints the largest and smallest values in the array?

final double[] ns = new double[10]; final Random rnd = new Random(System.currentTimeMillis()); // Fill... for (int i = 0; i < ns.length; ++i) { ns[i] = rnd.nextDouble(); } // Get largest/smallest... double largest = Double.MIN_VALUE; double smallest = Double.MAX_VALUE; for (double n : ns) { if (n > largest) { largest = n; } if (n < smallest) { smallest = n; } } // largest and smallest are now the proper values.


Write a c plus plus program to create a class car and aggregate it with wheel and engine parts?

You'll need to fill in the details, but the following framework will get you started. class Car { private: class Engine {}; // implementation omitted for brevity class Wheel {}; // implementation omitted for brevity Wheel m_front_wheel[2]; // array of two front wheels Wheel m_rear_wheel[2]; // array of two rear wheels Engine m_engine; // an engine }; int main() { Car ferrari; Car bmw; Car smart_car; return( 0 ); }


What is the container object that holds a fixed number of values of single type?

There are multiple answers to this question, but the most basic one common to both Java and C is the array. An array is a simple structure that you initialize to a certain size and fill with data. Think of an array as a sort of list, where each element in the list is numbered starting from zero up to the list size minus one (or the array is zero-based, as it's also called). In Java: // 10 is the number of elements the array can hold int[] myIntArray = new int[10]; myIntArray[0] = 2; // The first element in the array myIntArray[9] = 4; // The last element in the array Referencing myIntArray[10] or higher will cause a runtime error in Java, which may stop your program. In C: // 10 is the number of elements the array can hold int myIntArray[10]; myIntArray[0] = 2; // The first element in the array myIntArray[9] = 4; // The last element in the array Referencing myIntArray[10] or higher results in a buffer overflow in C (and C++). Note that in C, this won't throw errors like they do in Java, and this can and very likely will cause your program to have random bugs and possibly even crash from a segmentation fault, so be a bit more careful about using arrays in C.

Related questions

Write a c programme to draw a rainbow?

Write a C program to Draw a RAINBOW and fill the suitable colors ...


Write a program to declare 10 variables randomly and fill the array evenly using c plus plus?

#include<iostream> #include<chrono> #include<random> #include<vector> int main() { std::vector<int> Array; unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); std::default_random_engine generator (seed); std::uniform_real_distribution<int> distribution (0,100); for (size_t index=0; index<10; ++index) Array.push_back (distribution (generator)); }


Write a program that randomly fills a 10 component array then prints the largest and smallest values in the array?

final double[] ns = new double[10]; final Random rnd = new Random(System.currentTimeMillis()); // Fill... for (int i = 0; i < ns.length; ++i) { ns[i] = rnd.nextDouble(); } // Get largest/smallest... double largest = Double.MIN_VALUE; double smallest = Double.MAX_VALUE; for (double n : ns) { if (n > largest) { largest = n; } if (n < smallest) { smallest = n; } } // largest and smallest are now the proper values.


How do you create a program that will let the user to enter 10 numbers and arrange it in ascending and descending?

#include "stdio.h" #define ARRAY_SIZE 10 void fill(float* array, int size); void spill(float* array, int size, char* delimiter); void bubble_sort(float* array, int size); void reverse(float* array, int size); void swap(float* a, float* b); int main(int argc, char* argv[]) { float numbers[ARRAY_SIZE]; fill(numbers, ARRAY_SIZE); bubble_sort(numbers, ARRAY_SIZE); spill(numbers, ARRAY_SIZE, " "); reverse(numbers, ARRAY_SIZE); spill(numbers, ARRAY_SIZE, " "); return 0; } void fill(float* array, int size) { int i = 0; while (i < size) fscanf(stdin, "%f", array + (i++)); } void spill(float* array, int size, char* delimiter) { int i = 0; while (i < size) fprintf(stdout, "%f%s", array[i++], delimiter); fputc('\n', stdout); } void bubble_sort(float* array, int size) { int i, j; for (i = 0; i < size; i++) for (j = i; j < size; j++) if (array[i] > array[j]) swap(array + i, array + j); } void reverse(float* array, int size) { int i; for (i = size / 2; i >= 0; i--) swap(array + i, array + (size - (i + 1))); } void swap(float* a, float* b) { float c = *a; *a = *b; *b = c; } fill gets the numbers from input spill sends them to output bubble sort will sort the array in ascending order reverse will reverse the list so that it is in descending order swap is used to swap two floats You can change float to double or int depending on which datatype you want to use.


Write a c plus plus program to create a class car and aggregate it with wheel and engine parts?

You'll need to fill in the details, but the following framework will get you started. class Car { private: class Engine {}; // implementation omitted for brevity class Wheel {}; // implementation omitted for brevity Wheel m_front_wheel[2]; // array of two front wheels Wheel m_rear_wheel[2]; // array of two rear wheels Engine m_engine; // an engine }; int main() { Car ferrari; Car bmw; Car smart_car; return( 0 ); }


How do you write a sentence with fill?

Please fill the ewer with water.


How do you fill out a envelope to the country of Peru?

You write the address and then you eat it. You write the address and then you eat it.


Fill in the blank for the name of the TV program with Dave Attell?

Insomniac


What is the container object that holds a fixed number of values of single type?

There are multiple answers to this question, but the most basic one common to both Java and C is the array. An array is a simple structure that you initialize to a certain size and fill with data. Think of an array as a sort of list, where each element in the list is numbered starting from zero up to the list size minus one (or the array is zero-based, as it's also called). In Java: // 10 is the number of elements the array can hold int[] myIntArray = new int[10]; myIntArray[0] = 2; // The first element in the array myIntArray[9] = 4; // The last element in the array Referencing myIntArray[10] or higher will cause a runtime error in Java, which may stop your program. In C: // 10 is the number of elements the array can hold int myIntArray[10]; myIntArray[0] = 2; // The first element in the array myIntArray[9] = 4; // The last element in the array Referencing myIntArray[10] or higher results in a buffer overflow in C (and C++). Note that in C, this won't throw errors like they do in Java, and this can and very likely will cause your program to have random bugs and possibly even crash from a segmentation fault, so be a bit more careful about using arrays in C.


How do you turn an Excel cell a colour by pressing one button?

Click on the Fill Color tool icon. You could also write a macro to change the colour and assign it to a button on the worksheet.Click on the Fill Color tool icon. You could also write a macro to change the colour and assign it to a button on the worksheet.Click on the Fill Color tool icon. You could also write a macro to change the colour and assign it to a button on the worksheet.Click on the Fill Color tool icon. You could also write a macro to change the colour and assign it to a button on the worksheet.Click on the Fill Color tool icon. You could also write a macro to change the colour and assign it to a button on the worksheet.Click on the Fill Color tool icon. You could also write a macro to change the colour and assign it to a button on the worksheet.Click on the Fill Color tool icon. You could also write a macro to change the colour and assign it to a button on the worksheet.Click on the Fill Color tool icon. You could also write a macro to change the colour and assign it to a button on the worksheet.Click on the Fill Color tool icon. You could also write a macro to change the colour and assign it to a button on the worksheet.Click on the Fill Color tool icon. You could also write a macro to change the colour and assign it to a button on the worksheet.Click on the Fill Color tool icon. You could also write a macro to change the colour and assign it to a button on the worksheet.


How do you write 21 r 5?

21 5/x (Write as this, but fill in what you divided with where X is.)


Fill in the blank for the 1987 TV program Teenage Mutant?

Ninja Turtles