hello everyone, i have some question here which i had answered , just need some help with the correction, kindly pls point out my mistake.
with explanation will be great. thank you.
1] Write a single C statement to accomplish eah of the following:
i) Declare the variables c and this Variable to be of type int.
ii) Read an integer -a from the keyboard.
iii) Print the message "This is a C program." on two lines where the first line ends with C.
iv) Print the message "This is easy." with each word seperated by tabs.
v) Print the message in each of the following statements and rewrite the erroneous statements:
i) int c;
ii) scanf("%c", &c);
iii) printf("This is a C \n program.");
iv) printf("This \t is \t easy");
v) printf("\n How are you?");
2] Identify the errors in each of the following statements and rewrite the erroneous statements:
i) printf("The value is %i\n", &number);
ii) scanf("%i%i", &number1, number2);
iii) if (a>7); printf("A is greater than 7");
iv) if (c=>10) printf("C is equal or less than 10");
i) printf("The value is %i", &number);
iii) if (a>7)
printf("A is greater than 7");
iv) if (c=>10)
printf("C is equal or less than 10");
3] Given the following statements, identify whether TRUE or FALSE.
i) When the printf statement function is called it always begins printing at the begining of a new line. --- FALSE
ii) All variable must be declared before they are used.--- TRUE
iii) All variables must be given a type when they are declared.--- TRUE
iv) C consider the variables number and NUMBER to be identical. --- FALSE
v) The arithmetic operators *, /, %, + and - all have same level of precedence. --- FALSE
vi) The declaration of "char x" will automatically put zeroes throughout x.--- TRUE
vii) A string variable control string can be sent to scanf as its first argument. --- FALSE
viii) The strlen function returns the number of characters in its argument, and does count the null.--- TRUE
ix) C cannot tell the difference betwen program and data files. --- FALSE
x) C checks for subscripts that are out of range of an array's declared size. --- FALSE
4] Write four different C statements that each add 1 to integer variable x.
5] Choose the one answer which best fits the question.
i) Enclosing something entirely within something else is called ___.
ii) The selection structure ___.
a. decides what value data will take.
b. selects the result that is assigned to a variable.
c.choose one of two or more modules to execute.
iii) The relational operators have ___ associatively.
c. none of the above.
iv) Which of the following is not a relational operator in C?
v) More comparisons are tied together with ___.
b. logical operators
c. assigment operators
vi) The ___ operaor has higher precedence.
a. | |
vii) In the expression ((3<=4 | | a)&& 8 = = x), the ___ would be evaluated last.
b. | |
viii) Which of the following is not a C reserved word?
ix) The ___ stream is normally associated with the keyboard.
x) The first arguments to the print function is called the ___.
b. the addrress of the variable to print
6] Fill in the blanks for the following statements.
i) A ___ loop begins with a do statement. Answer:--- for
ii) A ___ loop begins with a while statement. Answer:--- while
iii) ___ and ___ operators, which also make assigments, are often used in counting loops. Answer:
iv) One loop within another is known as ___ loops. Answer:--- nested
v) A ___ has either True or False outcome. Answer:--- if