Question

at what times we can use 1 dimensional array strings for I,e char s[10]; and when...

at what times we can use 1 dimensional array strings for I,e char s[10];

and when can we use i.e char s[2][10] ;

Can you please let me know the diff

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

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

We use 1 dimension string basically to store a string into it or a bunch of characters.

But when we come to 2-D char array it basically stores a bunch of strings.

So, to store bunch of characters we use 1-D array and to store bunch of strings we use 2-D array

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
at what times we can use 1 dimensional array strings for I,e char s[10]; and when...
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
  • Note wordBank, an array of 10 strings (char *s). Your program should do the following: 1....

    Note wordBank, an array of 10 strings (char *s). Your program should do the following: 1. Select a word at random from the wordBank. This is done for you. 2. On each turn display the word, with letters not yet guessed showing as *'s, and letters that have been guessed showing in their correct location 3. The user should have 10 attempts (?lives?). Each unsuccessful guess costs one attempt. Successful guesses do NOT count as a turn. 4. You must...

  • I'm trying to use the execvp() command with an array of strings initialized like: char arr[4][100];...

    I'm trying to use the execvp() command with an array of strings initialized like: char arr[4][100]; in this array I have the program executable (arr[0]), and its arguments (arr[1], arr[2], arr[3]) stored. The man page for execvp requires: execvp(filepath, char *args[]) I was wondering if I could convert the contents of my char arr[][] array into an array of char *arr[]???

  • #include<stdio.h> #include<stdio.h> int main(){ int i; //initialize array char array[10] = {“Smith”, “Owen”, “Kowalczyk”, “Glass”, “Bierling”,...

    #include<stdio.h> #include<stdio.h> int main(){ int i; //initialize array char array[10] = {“Smith”, “Owen”, “Kowalczyk”, “Glass”, “Bierling”, “Hanenburg”, “Rhoderick”, “Pearce”, “Raymond”, “Kamphuis”}; for(int i=0; i<8;i++){ for(int j=0; j<9; j++){ if(strcmp(array[j],array[j+1])>0){ char temp[20]; strcpy(temp,array[j]); strcpy(array[j],array[j+1]); strcpy(array[j+1],temp); } } } printf(“---------File Names---------\n”); for(inti=0; i<9; i++){ printf(“\t%s\n”,array[i]); } printf(-------5 Largest Files according to sorting----\n”); for(int i=0;i>=5;i--) { printf(“\t%s\n”,array[i]); } return0; } Consider the "sort" program (using with void* parameters in the bubblesort function) from the week 10 "sort void" lecture. Modify it as follows...

  • Lab 2: (one task for Program 5): Declare an array of C-strings to hold course names,...

    Lab 2: (one task for Program 5): Declare an array of C-strings to hold course names, and read in course names from an input file. Then do the output to show each course name that was read in. See Chapter 8 section on "C-Strings", and the section "Arrays of Strings and C-strings", which gives an example related to this lab. Declare the array for course names as a 2-D char array: char courseNames[10] [ 50]; -each row will be a...

  • 2. 9 marks] Strings. Consider the following definitions on strings Let U be the set of all strings Let s be a str...

    2. 9 marks] Strings. Consider the following definitions on strings Let U be the set of all strings Let s be a string. The length or size of a string, denoted Is, is the number of characters in s Let s be a string, and i e N such that 0 < ί < sl. We write s[i] to represent the character of s at index i, where indexing starts at 0 (so s 0] is the first character, and...

  • DESCRIPTION: You will be given a 1-D array, called wordFun, of Strings. The array has an...

    DESCRIPTION: You will be given a 1-D array, called wordFun, of Strings. The array has an unknown number of cells filled with data. As before, the array will already be filled with strings, some of which contain the string "Angela". You will create a method called countItUp which returns and integer array containing the number of times each of the letters in my name occur within the strings within this array. For example, if the input array was wordFun =...

  • DESCRIPTION: You will be given a 1-D array, called wordFun, of Strings. The array has an...

    DESCRIPTION: You will be given a 1-D array, called wordFun, of Strings. The array has an unknown number of cells filled with data. As before, the array will already be filled with strings, some of which contain the string "Angela". You will create a method called countItUp which returns and integer array containing the number of times each of the letters in my name occur within the strings within this array. For example, if the input array was wordFun =...

  • C code only! Complete this function so that the function str2int convert the char array s...

    C code only! Complete this function so that the function str2int convert the char array s into its equivalent integer value. The char array has only digit characters of{0, 1, .., 9}and ’\0’.And the first element is not 0, which means, the integer string in the char array is of base 10. For example, if we pass chars[] = ”123” intostr2int, then it should return 123.Close the braces when you are done int str2int(char s[]){

  • Consider the following two-dimensional array: String [ ][ ] states = { { "CA", "CO" },...

    Consider the following two-dimensional array: String [ ][ ] states = { { "CA", "CO" },      { "MD", "IL", "ME", "MI" }, { "NY", "NJ", "NE" } }; What is the value of states[2][1] ? Retrieve ME from the array states and assign it to a String variable of your choice Using a loop, output all the states that start with the letter M in the second row (as in this example); assume that you do not know how...

  • hi i need help with b and e. I know when secondary and tertiary we use...

    hi i need help with b and e. I know when secondary and tertiary we use E1 mechanism and when primary E2. Please can you see if correct and explain the mechanism E2 and if it was primary how it would be with E1 H2SO4 e. (hint rearrangement)

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