Unit-4(Question_Bank).pdf

Full Transcript

Questions based on unit-4 Arrays 1. What is an array in C? 2. Why do we use arrays in C programming? 3. How are elements of an array stored in memory? 4. Explain how to declare a one-dimensional array in C. 5. How can you initialize an array during it...

Questions based on unit-4 Arrays 1. What is an array in C? 2. Why do we use arrays in C programming? 3. How are elements of an array stored in memory? 4. Explain how to declare a one-dimensional array in C. 5. How can you initialize an array during its declaration? Give an example. 6. Write a program to input values into an array and display them. 7. What is the difference between a single-dimensional and multi-dimensional array? 8. Write a program to find even and odd numbers in an array. 9. How do you count the number of even and odd numbers in an array? 10. How do you declare and initialize a two-dimensional array in C? 11. What is the syntax for accessing the elements of a two-dimensional array? Character Strings 12. What is a string in C programming? 13. How is a string different from a character array in C? 14. Explain how to declare a string in C. 15. What is the importance of the NULL (‘\0’) character in C strings? 16. How do you initialize a string without specifying its size? 17. Write the syntax to declare a string literal with a predefined size. 18. Explain how to assign a string character by character in C. 19. How do you read a string from the terminal using scanf()? 20. Write a program that reads a full sentence string using the gets() function. String Functions 21. How does the printf() function differ from puts() when printing a string? 22. How does the scanf() function differ from gets() 23. What is the function of the strlen() function in C? 24. Write a program to calculate the length of a string using strlen(). 25. How do you copy a string in C using the strcpy() function? 26. Write a program to copy a string using strcpy(). Matrix Operations 27. Explain the basic form of initializing a two-dimensional array. How can we declare an array arr. 28. Write a program to input and display a user-defined matrix. 29. Write a program for adding two matrices. 30. How can you print the elements of a two-dimensional array using nested loops?

Use Quizgecko on...
Browser
Browser