Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
co_assign_1_ques_1
#include<stdio.h> void charbinary(char c) { int q; for (int i = 7; i >= 0; --i) { q=(c & (1 << i))? 1 :0; printf("%d",q); } } void binary(int c,int size) { int q; for (int i = size; i >= 0; --i) { q=(c & (1 << i))? 1 :0; printf("%d",q); } } typedef union { float f; struct { unsigned int mantissa : 23; unsigned int exponent : 8; unsigned int sign : 1; } field; } myfloat; typedef union { double d; struct { unsigned long int mantissa : 52; unsigned int exponent : 11; unsigned int sign : 1; } field; }Double; int main(){ char ch; int i; printf("enter a char: "); scanf("%c",&ch); printf("enter an integer:"); scanf("%d",&i); myfloat var; printf("Enter a float : "); scanf("%f",&var.f); Double dou; printf("Enter a double : "); scanf("%lf",&dou.d); printf("\ninternal representation of,\n"); printf("char(%c): ",ch); charbinary(ch); printf("\n"); printf("int(%d): ",i); binary(i,15); printf("\n"); printf("float(%f): ",var.f); printf("%d ",var.field.sign); binary(var.field.exponent, 7); printf(" "); binary(var.field.mantissa, 22); printf("\n"); printf("double(%lf): ",dou.d); printf("%d ",dou.field.sign); binary(dou.field.exponent, 10); printf(" "); binary(dou.field.mantissa, 5); return 0; }
run
|
edit
|
history
|
help
0
3 and 7 in a row
qwerty
sd
Connected components in complement graph
backtracking
list
std_minmax_unexpected_behaviour.cpp
code
constructing object on first use as return value of (pointer to) object-returning function
c1