Tested code -
#include<stdio.h> main() { int num; printf("Enter a number\n"); scanf("%d",&num); num=(num+1)|num; printf("%d\n", num); }
#include<stdio.h> main() { int num,i; printf("Enter a number\n"); scanf("%d",&num); num=num|1; for(i=31;i>=0;i--) { if(num&1<<i) printf("1"); else printf("0"); if(i%4==0) printf("\t"); } printf("\n"); }
Using fprintf() print a single floating point number right-justified in a field of 20 spaces, no leading zeros, and 4 decimal places. The destination should be stderr and the variable is called num.
input: one two three
output: three two one