Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8456587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:34:55+00:00 2026-06-10T12:34:55+00:00

#include<stdio.h> int main() { char ch = ‘A’; printf(%d\n,’ag’); printf(%d\n,’a’); printf(%d, %d, %d, %d,

  • 0
         #include<stdio.h>

         int main()
         {

           char ch = 'A';

           printf("%d\n",'ag');

           printf("%d\n",'a');

           printf("%d, %d, %d, %d", sizeof(ch), sizeof('a'), sizeof('Ag'), sizeof(3.14f));

          return 0;
         }

I used to have many doubts on the output of this question while running on g++ and gcc.

But I have cleared almost all the doubts by referring these links:

  1. Single, double quotes and sizeof('a') in C/C++

  2. Single quotes vs. double quotes in C or C++

I still need to understand one thing about the output of this question.

Can someone please explain the output of printf("%d\n",'ag'); mentioned above in the program. How is it actually stored in the memory?

The output for the program on the Linux/GCC platform is:

24935
97
1, 4, 4, 4
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:34:57+00:00Added an answer on June 10, 2026 at 12:34 pm

    The type of a single-quoted literal is int. So the size is typically large enough for more than one character’s worth of bits. The exact way the characters are interpreted is, as far as I know, implementation-dependent.

    In your case, you’re getting a little-endian ordering:

    • The ASCII value for 'a' is 97 (0x61)
    • The ASCII value for 'g' is 103 (0x67)

    Your value is 24935 = 0x6167, so you’re getting the 'a' in the higher byte and the 'g' in the lower.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this program #include <stdio.h> int main() { char arr[100]; printf(%d, (int)sizeof(0,arr)); }
#include<stdio.h> int main() { char a, b; scanf(%c, &a); scanf(%c, &b); printf(%c %c,a,b); return
#include <stdio.h> int main() { char temp[1024]; if(getchar() != 'y') { printf(no options\n); return
#include <stdio.h> #include <stdlib.h> int main() { char *str=Helloworld; printf(%d,printf(%s,str)); return 0; } output
Check out this program #include<stdio.h> int main (){ char c='a'; printf(%d %d, sizeof(c),sizeof('a')); }
#include<stdio.h> int main() { char a='x'; printf(%c %d,a); return 0; } Output: x 134513696
#include<stdio.h> int main() { char str[25] = helloworld; printf(%s %s, &str+2,str+2); return 0; }
#include<string.h> #include<stdio.h> int main() { char* charPtr=see me; printf(%s\n, charPtr); printf(%d, charPtr); return 0;
#include<stdio.h> #include<string.h> int main() { char a[]=aaa; char *b=bbb; strcpy(a,cc); printf(%s,a); strcpy(b,dd); printf(%s,b); return
#include <stdio.h> int main() { char TurHare; while(1) { scanf(%c,TurHare); printf(\nCharacter :%c, TurHare); }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.