Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

1.

A string literal is placed always placed in double


quotes(“”), while a character literal is placed in single
quotes(‘’).
2. Escape sequences are used to represent certain special
characters within string literals and character literals. And
these characters in a literal string are meant to indicate
that the next character should not be interpreted in the
usual way.
3. #include<iostream>
int main();

int main()
{
std::cout<< ”Hello world” <<std::endl; //string
std::cout<< ’a’ <<std::endl; //character
std::cout<< 32 <<std::endl;//integer
std::cout<< true< <std::endl;//bool
std::cout<< 3.0 <<std::endl;//floating point
return 0;
}

4.

When (‘) is printed to the console as a character literal by


being written within single quotes, the compile doesn’t
interpret it as a character and displays an error message
that terminating ‘ is missing. But when (\’) is printed to
the console the compiler interprets it as a character and
prints to the console. When (‘) is printed to the console as
a string literal by being written within double quotes, the
compile doesn’t interpret it as a character, but instead as
a string and hence prints it to the console without any
error.
5.

6.
7.

8. A)

 The compiler does not recognize the function


get_course_number() because the function is not declared
before int main(), but instead it is declared after
int main(). And hence, int main() is not aware of the
function get_course_number().

 The compiler does not recognize the function


get_assignment_number() because the function is not
declared before int main(), but instead it is declared
after int main(). And hence, int main() is not aware of
the function get_assignment_number().
B)

9.
10.
11.
12.
13.
14.
15.

You might also like