answersLogoWhite

0

Yes, you can but the array must be char-type. ... int arraySize = 3;

char myArray[arraySize]; ... for (intarrayIndex = 0; arrayIndex < arraySize; arrayInsex++) { cin >> myArray[arrayIndex]; //It will write three character (keys which you pressed) in myArray

} ...

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

How do you write a c plus plus program that will average 10 numbers entered and print the array?

#include&lt;iostream&gt; #include&lt;sstream&gt; #include&lt;vector&gt; using namespace std; int main() { vector&lt;int&gt; Array; for (size_t index=0; index&lt;9; ++index) { int i; bool valid = false; while (!valid) { cout &lt;&lt; "Enter a number: "; string input; cin &gt;&gt; input; stringstream ss; ss &lt;&lt; input; valid = (ss &gt;&gt; i); if (!valid) cout &lt;&lt; "Invalid input.\n"; } Array.push_back (i); } // print array and average int average=0; for (size_t index=0; index&lt;9; ++index) { cout &lt;&lt; Array[index] &lt;&lt; ' '; average += Array[index]; } average /= 10; cout &lt;&lt; "\nAverage: " &lt;&lt; average &lt;&lt; endl; }


How do you write a C program to find the largest of 10 integers in an array?

#include&lt;stdio.h&gt; // returns the index of the largest value in the array int max (int a[], unsigned size) { if (!size) return -1; // invalid array int index = 0; // assume index 0 holds the largest value (so far) for (int i=1; i&lt;size; ++i) { // traverse the remainder of the array if (a[i]&gt;a[index]) { // compare with the current largest index = i; // the current value is larger } } return index; // a[index] holds the largest value } int main (void) { int x[10] = {7, 4, 3, 9, 5, 2, 1, 8, 6}; printf ("The largest value in the array is %d\n", max (x, 10)); return 0; }


How do I write a program that converts sentences into Morse code?

This is done with an algorithm that takes a text string and process each letter in turn. In computing text letters are usually coded as ASCII characters where the character is encoded as a specific numeric value. The algorithm will obtain this value and use it as in index into an array storing the Morse Code representation for every ASCII character. The output of the algorithm with thus be a Morse translation of the text input.


How can you fix an ArrayIndexOutOfBoundsException in java?

This is very common exception and name of the exception class tells exactly what kind of problem you have. If you would look into stack trace, which should have been generated too you would be able to find exact place where it happened. The problem is that "Array Index Out Of Bounds". This means that you used index on array which is invalid. That could negative number, because all arrays starts from 0. If you array has N items and you will try to get item with index N or higher you will get this exception too. Only available indexes are from 0 to N - 1, where 0 points to the first item and N - 1 to the last one.


How will you Write a c program to find the kth smallest element in an array in c?

//This is for kth largest element. (So this is for n-k smallest element) //Sudipta Kundu [Wipro Technologies] #include &lt;stdio.h&gt; //Input: array with index range [first, last) //Output: new index of the pivot. An element in the middle is chosen to be a pivot. Then the array's elements are //placed in such way that all elements &lt;= pivot are to the left and all elements &gt;= pivot are to the right. int positionPivot(int* array, int first, int last); //Input: array with index range [first, last) and integer K (first &lt;= K &lt; last) //Output: array whose Kth element (i.e. array[K]) has the "correct" position. More precisely, //array[first ... K - 1] &lt;= array[K] &lt;= array[K + 1 ... last - 1] void positionKthElement(int* array, int first, int last, int k); int main() { int array[] = {7,1,8,3,1,9,4,8}; int i; for (i = 0; i &lt; 8; i++) { positionKthElement(array, 0, sizeof(array) / sizeof(array[0]),i); printf("%d is at position %d\n", array[i], i); } return 0; } int positionPivot(int* array, int first, int last) { if (first last) return first; int tmp = (first + last) / 2; int pivot = array[tmp]; int movingUp = first + 1; int movingDown = last - 1; array[tmp] = array[first]; array[first] = pivot; while (movingUp &lt;= movingDown) { while (movingUp &lt;= movingDown &amp;&amp; array[movingUp] &lt; pivot) ++movingUp; while (pivot &lt; array[movingDown]) --movingDown; if (movingUp &lt;= movingDown) { tmp = array[movingUp]; array[movingUp] = array[movingDown]; array[movingDown] = tmp; ++movingUp; --movingDown; } } array[first] = array[movingDown]; array[movingDown] = pivot; return movingDown; } void positionKthElement(int* array, int first, int last, int k) { int index; while ((index = positionPivot(array, first, last)) != k) { if (k &lt; index) last = index; else first = index + 1; } }


How are arrays processed?

Usually one element at a time. If you want to process all elements of an array, you write a loop.Usually one element at a time. If you want to process all elements of an array, you write a loop.Usually one element at a time. If you want to process all elements of an array, you write a loop.Usually one element at a time. If you want to process all elements of an array, you write a loop.


How do you write index in Hindi?

You can write index in Hindi as &quot;सूची&quot; (pronounced as &quot;soochi&quot;).


How do you write Index?

formula for writing index


Write a program to display biggest integer in a one Dimensional array using pointer?

#include&lt;iostream&gt; int max(int* a, size_t size) { size_t max=a[0]; for(size_t index=0; index&lt;size; ++index) if( max&lt;a[index] ) max=a[index]; return( max ) } int main() { int a[5]={1,5,8,7,4}; int m=max(a,5); // invariant: m==8 }


Write a java program that tests the presence of the number 90 in an array of 70 90 80?

// set up array int[] nums = new int[] {70, 90, 80}; // iterate and search for(int i = 0; i &lt; nums.length; ++i) { if(nums[i] == 90) { System.out.println("Found 90 at index: " + i); } }


How 2 write c code of array data structure?

An example: int array [10]; yaaa this is write but for a simple programs on array and all data structure visit codingdatastructure.blogspot.com


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

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