2. Write a c program to convert decimal number to octal number.
3. Write a c program to convert decimal number to hexadecimal number.
4. Write a c program to convert octal number to binary number.
3. Write a c program to convert decimal number to hexadecimal number.
4. Write a c program to convert octal number to binary number.
6. Write a c program to convert octal number to hexadecimal number.
8. Write a c program to convert hexadecimal number to octal number.
9. Write a c program to convert hexadecimal number to decimal number.
10. Write a c program to convert binary number to octal number.
9. Write a c program to convert hexadecimal number to decimal number.
10. Write a c program to convert binary number to octal number.
12. Write a c program to convert binary number to hexadecimal number.
13. C program for addition of binary numbers .
14. C program for multiplication of two binary numbers.
15. C program fractional binary conversion from decimal.
16. C program for fractional decimal to binary fraction conversion.
17. C program to convert decimal number to roman.
18. C program to convert roman number to decimal number.
19. C program to convert each digits of a number in words
20. C program to convert currency or number in word.
13. C program for addition of binary numbers .
14. C program for multiplication of two binary numbers.
15. C program fractional binary conversion from decimal.
16. C program for fractional decimal to binary fraction conversion.
17. C program to convert decimal number to roman.
18. C program to convert roman number to decimal number.
19. C program to convert each digits of a number in words
20. C program to convert currency or number in word.
10 comments:
much better program with not so many conditionals.
---------------------------------------------------
#include
#include
#include
void reverse(char a[]);
void roman(int x,char a[],int i);
char values[4][3] = {{'I','V','X'},{'X','L','C'},{'C','D','M'},{'C'}};
main()
{
clrscr();
char final[20] = {'\0'};
int num,x,i=0;
printf("Enter the number that you want to convert to Roman Numerals:");
scanf("%d",&num);
if (num>5399)
num=0;
while(num)
{
x = num%10;
num /=10;
roman(x,final,i);
i++;
}
reverse(final);
printf("%s",&final);
getch();
return 1;
}
void roman(int x, char final[],int i)
{
int j=0,k=0,flag=0;
while (final[j]!='\0')
j++;
if(x<4)
{
for (k=0;k4)&&(x<9))
{
k=x-5;
final[j++]=values[i][1];
while (k)
{
final[j++]=values[i][0];
k--;
}
flag=1;
}
else if (x==9)
{
final[j++]=values[i][0];
final[j++]=values[i+1][0];
flag=1;
}
if(flag)
final[j++]='\0';
}
void reverse(char string[])
{
int j=0,k=0;
char temp[50];
while(string[j])
j++;
while(j)
temp[--j]=string[k++];
temp[k]='\0';
strcpy(string,temp);
}
------------------------------------------------
the formatting of the website removed all the indentation.
void dec2romanstr(int num){
int del[] = {1000,900,500,400,100,90,50,40,10,9,5,4,1};
char * sym[] = { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" };
char res[64] = "\0";
int i = 0;
while (num){
while (num/del[i]){
strcat(res, sym[i]);
num -= del[i];
}
i++;
}
puts(res);
}
Sir this program is not working for the number: 495.....i dont know why this error s occuring and i m unable to debug ur program as well so i kindly request you to provide a correct program ........
#include
int main ()
{int year,q,w,e,r,t,y,u,i,o;
printf("enter ur num");
scanf("%d",&year);
q=year/1000;
w=year%1000;
e=w/100;
r=w%100;
t=r/10;
y=r%10;
for(u=1;u<=q;u++)
printf("M");
if(e>=5)
{printf("D");
for(u=1;u<=(e-5);u++)
printf("C");
}
if(e<5)
{
for(u=1;u<=e;u++)
printf("C");
}
if(t>=5)
{printf("L");
for(u=1;u<=(t-5);u++)
printf("X");
}
if(t<5)
{
for(u=1;u<=t;u++)
printf("X");
}
if(y>=5)
{printf("V");
for(u=1;u<=(y-5);u++)
printf("I");
}
if(y<5)
{
for(u=1;u<=y;u++)
printf("I");
}
return 0;
}
#include
int main ()
{int year,q,w,e,r,t,y,u,i,o;
printf("enter ur num");
scanf("%d",&year);
q=year/1000;
w=year%1000;
e=w/100;
r=w%100;
t=r/10;
y=r%10;
for(u=1;u<=q;u++)
printf("M");
if(e>=5)
{printf("D");
for(u=1;u<=(e-5);u++)
printf("C");
}
if(e<5)
{
for(u=1;u<=e;u++)
printf("C");
}
if(t>=5)
{printf("L");
for(u=1;u<=(t-5);u++)
printf("X");
}
if(t<5)
{
for(u=1;u<=t;u++)
printf("X");
}
if(y>=5)
{printf("V");
for(u=1;u<=(y-5);u++)
printf("I");
}
if(y<5)
{
for(u=1;u<=y;u++)
printf("I");
}
return 0;
}
you have to change the part:
predigits('L','D');
number = number - (500-100);
TO
predigits('C','D');
number = number - (500-100);
right...
lol
check the numebr 499
the output will be ldxcix
which is the output for 549
Post a Comment