#include<stdio.h> #include<conio.h> void main() { int bin[10],n,num,i,dig,j,opt; char c; clrscr(); do { printf("***Menu***\n1.Decimal to Binary\n2.Decimal to Octal\n3.Exit"); printf("\nEnter Ur choice: "); scanf("%d",&opt); switch(opt) { case 1: printf("Enter Decimal number: "); scanf("%d",&n); num=n; i=0; while(n>0) { dig=n%2; bin[i]=dig; n=n/2; i++; } printf("Equivalent Binary of Decimal %d is :",num); for(j=i-1;j>=0;j--) printf(" %d",bin[j]); break; case 2: printf("Enter Decimal number: "); scanf("%d",&n); i=0; num=n; while(n>0) { dig=n%8; bin[i]=dig; n=n/8; i++; } printf("Equivalent Octal of Decimal %d is :",num); for(j=i-1;j>=0;j--) printf(" %d",bin[j]); break; case 3: exit(0); break; default: printf("*****Invalid Choice*****"); } printf("\nDo U want to Continue (y/n): "); fflush(stdin); c=getchar(); }while(c=='Y'||c=='y'); getch(); }
C Program To Convert Decimal to Binary Decimal to Octal
January 02, 2015
By:
Bhanu Namikaze
Bhanu Namikaze
Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.
No comments:
Post a Comment