I/O Using C Functions

Estudies4you
Q24. Write a program to display the given decimal number in hexadecimal and octal format using manipulators.
Answer:
Program
#include<iostream.h>
#include<iomanip.h>
#include<conio.h>
int main()
{
clrscr();
int a = 90;
cout<<“\n The Hexadecimal Number for the given decimal number is: ” <<hex <<a;
cout<<“\n The Octal Number for the given decimal number is: ” <<oct<<a;
getch( );
return 0;
}
Output
I/O Using C Functions
In this program, a decimal number or an integer is initialized with 90. Then the cout statements are used to display the equivalent hexadecimal and octal number using hex and oct manipulators respectively.

To Top