#include<stdio.h>
#include<conio.h>
void main()
{
int x=01234;
printf("%d",x);
}
the above c code will produce output 668(value of x) why?
#include<stdio.h>
#include<conio.h>
void main()
{
int x=01234;
printf("%d",x);
}
the above c code will produce output 668(value of x) why?
Read up in your help files, on how int's with assigned values that begin with a zero, are interpreted by your compiler.
What would an assignment of 080 print up?
Read up in your help files, on how int's with assigned values that begin with a zero, are interpreted by your compiler.
What would an assignment of 080 print up?
the int x=080;
shows illegal octal digit error.
Exactly. The digit "8" does not exist in octal. The digits "1", "2", "3" and "4" do exist in octal.
Compiler treats number starting with 0 as octal number and 01234 is an octal number whose decimal value is 668 as you are printing it with %d specifier so it outputs 668.
check output for this instead:-
printf("%o",x);
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.