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 6033215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:27:05+00:00 2026-05-23T05:27:05+00:00

Here is a program #include <stdio.h> main() { unsigned char i=0x80; printf(i=%d,i<<1); } The

  • 0

Here is a program

#include <stdio.h>
main()
{ unsigned char i=0x80;
printf("i=%d",i<<1);
}

The output it is giving is 256.
I am not clear with what does

unsigned char i=0x80; <-- i is not int it is char so what will it store?

I know bitshift and hexadecimal things.
How is the value of i being stored and how does it gets changed to 256?

UPDATE

Why did overflow not occurred when the bit shift operation happened?

  • 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-05-23T05:27:06+00:00Added an answer on May 23, 2026 at 5:27 am

    In C, a char is an integer type used to store character data, typically 1 byte.

    The value stored in i is 0x80 a hexidecimal constant that is equal to 128.

    An arithmetic operation on two integer types (such as i << 1) will promote to the wider type, in this case to int, since 1 is an int constant. In any case, integer function arguments are promoted to int.

    Then you send the result to printf, with a %d format specifier, which mean “print an integer”.

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

Sidebar

Related Questions

Here is one program #include<stdio.h> #include<stdlib.h> int main() { unsigned char a=0x80; printf(%d\n,a<<1); }
The following C program: #include <stdio.h> int main(void) { printf("%u %u %u\n",sizeof "",sizeof(""+0),sizeof(char *));
Consider this little program: #include <stdio.h> int main() { char c = 0xFF; printf(%d\n,
Here is my program: #include <stdio.h> int main() { int a=0x09; int b=0x10; unsigned
Here is my code!(sorry for my poor english) #include<stdio.h> int convert(char ch); int main(void)
Here is my server program #include<stdio.h> #include<stdlib.h> #include<sys/socket.h> #include<sys/un.h> #include<sys/types.h> #include<unistd.h> int main ()
I wrote the following program: #include<stdio.h> int main(void) { float f; printf(\nInput a floating-point
I compile this program: #include <stdio.h> int main() { printf(Hello World!); return 0; }
Okay here's the program I have typed up(stdio.h is included also): /* function main
I have a program here: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ipc.h> #include

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.