Find error in the following statements and correct them? a) Const int n; b) Charc ="XYZ" ; c) # def msg "Hello World" ; d) Char n [ ] =Hellow world; e) float average =37.25 ;
Answers
Answered by
1
Answer:
Friend ,Your question is very confusing
Answered by
0
Statements with errors are b) Charc ="XYZ" ; and d) Char n [ ] =Hellow world;.
Corrected statements are Char c = "XYZ"; and Char n [] = "Hellow world"; respectively.
Explanation:
- We have been given a total of 4 statements
- We can find the incorrect statement by comparing the statements with their respective proper syntax.
- The first statement is Const int n; which is as per syntax and is valid.
- The second statement is Charc ="XYZ"; here there is no space between char and c, which is incorrect syntax and is an invalid statement. Correct statement will be Char c = "XYZ";
- The third statement is # def msg "Hello World"; which is as per syntax and is valid.
- The last statement is Char n [ ] =Hellow world; here the string Hellow world should be in inverted commas to assign it to an array. Correct statement will be Char n [] = "Hellow World";
Hence, Statements b) Charc ="XYZ" ; and d) Char n [ ] =Hellow world; have errors and corrected statements are Char c = "XYZ"; and Char n [] = "Hellow world"; respectively.
Similar questions