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:
pls give some description of this program.
Using c language, the input and output are 0 and 1. Its output is identical to the input in the even position but inverted in the odd position. For example, input 0000111 it output 1010010. How to do this ?
Check This Code
may be it is simpler than your code
#include
#include
int main()
{
int a[10],len,i,j,val;
char rom[20];
printf("Enter the Roman Numeral:");
scanf("%s",rom);
printf("%s",rom);
i=0;
while(rom[i]!='\0')
{
if(rom[i]=='I')
a[i]=1;
else if(rom[i]=='V')
a[i]=5;
else if(rom[i]=='X')
a[i]=10;
else if(rom[i]=='L')
a[i]=50;
else if(rom[i]=='C')
a[i]=100;
else if(rom[i]=='D')
a[i]=500;
else if(rom[i]=='M')
a[i]=1000;
printf("\n %d %d",a[i],i);
i++;
}
len=strlen(rom);
printf("\n %d\n",len);
for(i=len-1;i>=0;i--)
{
if(i!=0)
{
if(a[i]>a[i-1])
a[i-1]=a[i]-a[i-1];
else
val=val+a[i];
}
else
val=val+a[i];
}
printf("Its Decimal Equivalent is: %d",val);
return 0;
}
Could you explain this part for me?
if(digitValue(roman_Number[i]) >= digitValue(roman_Number[i+1]))
number = number + digitValue(roman_Number[i]);
else{
number = number + (digitValue(roman_Number[i+1]) - digitValue(roman_Number[i]));
i++;
}
i++;
}
This is probably the shortest/simplest solution to this problem
#include < stdio.h >
void main(){
char ROMAN[][3] = { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" };
int NUM[] = { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 };
char result[20] = { 0 };
int num, i;
printf("Enter a Number: ");
scanf("%i", &num);
printf("\nRoman Numeral.: ");
for(i = 0; num > 0 && num < 3999; i++)
while(num/NUM[i]){
printf("%s", ROMAN[i]);
num -= NUM[i];
}
getchar();
}
is it possible to have one that starts with
int romanToInt(char *s){
...
//and ends with
...
return -1;
} /* romanToInt */
is it possible to have one that starts with
int romanToInt(char *s){
...
//and ends with
...
return -1;
} /* romanToInt */
#include
int main()
{
int n,a=1;
printf("entetr the num.");
do
{
scanf("%d",&n);
while(n>=1000 || n>=900)
{
if(n>=1000)
printf("M",n=n-1000);
else if(n>=900)
printf("CM",n=n-900);
}
while(n>=500 || n>=400)
{
if(n>=500)
printf("D",n=n-500);
else if(n>=400)
printf("CD",n=n-400);
}
while(n>=100 || n>=90)
{
if(n>=100)
printf("C",n=n-100);
else if(n>=40)
printf("XC",n=n-40);
}
while(n>=50 || n>=40)
{
if(n>=50)
printf("L",n=n-50);
else if(n>=40)
printf("XL",n=n-40);
}
while(n>=10 || n>=9)
{
if(n>=10)
printf("X",n=n-10);
else if(n>=9)
printf("IX",n=n-9);
}
while(n>=5 || n>=4)
{
if(n>=5)
printf("V",n=n-5);
else if(n>=4)
printf("IV",n=n-4);
}
while(n>=1)
printf("I",n=n-1);
scanf("%d",&a);
}
while(a!=0);
return 0;
}
Post a Comment