1. Write a for loop statement that initializes all the diagonal elements of an array to one and
others to zero as shown below. Assume 5 rows and 5 columns.
2. Describe the limitations of using getchar and scanf functions for reading strings.
3. Character strings in C are automatically terminated by the null character. Explain how this
feature helps in string manipulations.
4. Strings can be assigned values as follows:
(a) During type declaration char string[ ] = {“.......”};
(b) Using strcpy function strcpy(string, “.......”);
(c) Reading using scanf function scanf(“%s”, string);
(d) Reading using gets function gets(string);
Compare them critically and describe situations where one is superior to the others.
5. Write a program, which reads your name from the keyboard and outputs a list of ASCII
codes, which represent your name.
Write a program to do the following:
(a) To output the question “Who is the inventor of C ?”
(b) To accept an answer.
(c) To print out “Good” and then stop, if the answer is correct.
(d) To output the message ‘try again’, if the answer is wrong.
(e) To display the correct answer when the answer is wrong even at the third attempt and stop.