How are long and long long integer literals represented in C++?

QuestionsQuestions8 SkillsProC++ Variables and TypesDec, 04 2025
0110

In C++, long and long long integer literals can be represented using specific suffixes to indicate their type. Here's how they are represented:

  1. Long Integer Literals:

    • You can represent a long integer literal by appending the suffix L or l to the number.
    • Example:
      long num1 = 1234567890L; // Long integer literal
  2. Long Long Integer Literals:

    • For long long integer literals, append the suffix LL or ll.
    • Example:
      long long num2 = 1234567890123456789LL; // Long long integer literal

Summary:

  • Use L or l for long integers.
  • Use LL or ll for long long integers.

These suffixes help the compiler understand the intended type of the literal, ensuring proper storage and operations. If you want to practice more with integer types in C++, consider checking out related labs on LabEx!

0 Comments

no data
Be the first to share your comment!