Home

A program to read integer and print it in decimal, octal, and hexadecimal form.

C Programming Language 003

The following code shows how to write a program to read integer and print it in decimal, octal, and hexadecimal form. Read float and print it in floating point notation and exponent notation.

Program

#include <stdio.h>

void main()
{
    int a;
    float b;
    printf("Enter a,b values: ");
    scanf("%d %f", &a, &b);
    printf("\ndecimal=%d", a);
    printf("\noctal = %o", a);
    printf("\nhexadecimal=%x", a);
    printf("\nfloating point=%f", b);
    printf("\nexponent=%e", b);

    printf("\n");
}

Result

Enter a,b values: 12 42

decimal=12
octal = 14
hexadecimal=c
floating point=42.000000
exponent=4.200000e+01


Last Updated on

Next Post: GraphProtocol: TS2322 null assignment in Subgraph →

Comments