SlideShare a Scribd company logo
1 of 6
/* 2’s complement of a number is obtained by scanning it from right to left and complementing all

the bits after the first appearance of a 1. Thus 2’s complement of 11100 is 00100.

Write a C program to find the 2’s complement of a binary number.*/



#include <stdio.h>

#include<conio.h>



void complement (char *a);

void main()

{

char a[16];

int i;

clrscr();

printf("Enter the binary number");

gets(a);

for(i=0;a[i]!='0'; i++)

{

    if (a[i]!='0' && a[i]!='1')

    {

    printf("The number entered is not a binary number. Enter the correct number");

    exit(0);

    }

}

complement(a);
getch();

}

void complement (char *a)

{

int l, i, c=0;

char b[16];

l=strlen(a);

for (i=l-1; i>=0; i--)

{

    if (a[i]=='0')

    b[i]='1';

    else

    b[i]='0';

}

for(i=l-1; i>=0; i--)

{

if(i==l-1)

{

    if (b[i]=='0')

    b[i]='1';

    else

    {

    b[i]='0';

    c=1;
}

}

else

{

    if(c==1 && b[i]=='0')

    {

    b[i]='1';

    c=0;

    }

else if (c==1 && b[i]=='1')

{

    b[i]='0';

    c=1;

}

}

}

b[l]='0';

printf("The 2's complement is %s", b);

}
/* Write a C program to convert a Roman numeral to its decimal equivalent. */



#include<stdio.h>

#include<conio.h>

#include<string.h>

#include<stdlib.h>



void main()

{



int *a,len,i,j,k;

char *rom;



clrscr();



printf("Enter the Roman Numeral:");

scanf("%s",rom);



len=strlen(rom);



for(i=0;i<len;i++)
{

    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;

    else

    {

        printf("nInvalid Value");

        getch();

        exit(0);

    }

}

k=a[len-1];

for(i=len-1;i>0;i--)
{

    if(a[i]>a[i-1])

    k=k-a[i-1];

    else if(a[i]==a[i-1] || a[i]<a[i-1])

    k=k+a[i-1];

}

printf("nIts Decimal Equivalent is:");

printf("%d",k);

getch();

}

More Related Content

What's hot

Add digits of number in c
Add digits of number in c Add digits of number in c
Add digits of number in c mohdshanu
 
Palindrome number program c
Palindrome number program cPalindrome number program c
Palindrome number program cmohdshanu
 
Computer programing w
Computer programing wComputer programing w
Computer programing wcexpertise
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Dr. Loganathan R
 
C Programming Language Part 4
C Programming Language Part 4C Programming Language Part 4
C Programming Language Part 4Rumman Ansari
 
Double linked list
Double linked listDouble linked list
Double linked listSayantan Sur
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)Syed Umair
 
C program to check leap year
C program to check leap year C program to check leap year
C program to check leap year mohdshanu
 
Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04hassaanciit
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given numberMainak Sasmal
 
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language One dimensional operation of Array in C- language
One dimensional operation of Array in C- language 9096308941
 

What's hot (20)

Add digits of number in c
Add digits of number in c Add digits of number in c
Add digits of number in c
 
Palindrome number program c
Palindrome number program cPalindrome number program c
Palindrome number program c
 
Computer programing w
Computer programing wComputer programing w
Computer programing w
 
Shan
ShanShan
Shan
 
Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4Bcsl 033 data and file structures lab s1-4
Bcsl 033 data and file structures lab s1-4
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
week-17x
week-17xweek-17x
week-17x
 
C Programming Language Part 4
C Programming Language Part 4C Programming Language Part 4
C Programming Language Part 4
 
Double linked list
Double linked listDouble linked list
Double linked list
 
New microsoft office word document (2)
New microsoft office word document (2)New microsoft office word document (2)
New microsoft office word document (2)
 
C program to check leap year
C program to check leap year C program to check leap year
C program to check leap year
 
week-8x
week-8xweek-8x
week-8x
 
งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์งานนำเสนอ อาจารย์ลาวัลย์
งานนำเสนอ อาจารย์ลาวัลย์
 
Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
 
Final ds record
Final ds recordFinal ds record
Final ds record
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 

Viewers also liked (10)

ch6
ch6ch6
ch6
 
ch14
ch14ch14
ch14
 
BrainFingerprintingpresentation
BrainFingerprintingpresentationBrainFingerprintingpresentation
BrainFingerprintingpresentation
 
DISTRIBUTED INTERACTIVE VIRTUAL ENVIRONMENT
DISTRIBUTED INTERACTIVE VIRTUAL ENVIRONMENTDISTRIBUTED INTERACTIVE VIRTUAL ENVIRONMENT
DISTRIBUTED INTERACTIVE VIRTUAL ENVIRONMENT
 
PPT (2)
PPT (2)PPT (2)
PPT (2)
 
week-3x
week-3xweek-3x
week-3x
 
week-5x
week-5xweek-5x
week-5x
 
week-2x
week-2xweek-2x
week-2x
 
C code examples
C code examplesC code examples
C code examples
 
week-23x
week-23xweek-23x
week-23x
 

Similar to week-10x

Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in CSaket Pathak
 
Bca 1st year C langauge .pdf
Bca 1st year C langauge .pdfBca 1st year C langauge .pdf
Bca 1st year C langauge .pdfRahul Saini
 
Write an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdfWrite an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdfaaryanentp
 
Write an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdfWrite an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdfagpcorp
 
PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfPCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfAshutoshprasad27
 
PCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxPCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxAshutoshprasad27
 
data structure and algorithm.pdf
data structure and algorithm.pdfdata structure and algorithm.pdf
data structure and algorithm.pdfAsrinath1
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020vrgokila
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solutionAzhar Javed
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans incnayakq
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given numberMainak Sasmal
 

Similar to week-10x (20)

Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
 
Bca 1st year C langauge .pdf
Bca 1st year C langauge .pdfBca 1st year C langauge .pdf
Bca 1st year C langauge .pdf
 
Write an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdfWrite an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdf
 
Write an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdfWrite an MPI program to accomplish the following for a numbe.pdf
Write an MPI program to accomplish the following for a numbe.pdf
 
PCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdfPCA-2 Programming and Solving 2nd Sem.pdf
PCA-2 Programming and Solving 2nd Sem.pdf
 
PCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docxPCA-2 Programming and Solving 2nd Sem.docx
PCA-2 Programming and Solving 2nd Sem.docx
 
data structure and algorithm.pdf
data structure and algorithm.pdfdata structure and algorithm.pdf
data structure and algorithm.pdf
 
C programm.pptx
C programm.pptxC programm.pptx
C programm.pptx
 
C programming
C programmingC programming
C programming
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Include
IncludeInclude
Include
 
C Programming
C ProgrammingC Programming
C Programming
 
Qust & ans inc
Qust & ans incQust & ans inc
Qust & ans inc
 
C faq pdf
C faq pdfC faq pdf
C faq pdf
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
C Programming
C ProgrammingC Programming
C Programming
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Lab Question
Lab QuestionLab Question
Lab Question
 

More from KITE www.kitecolleges.com (16)

ch16
ch16ch16
ch16
 
holographic versatile disc
holographic versatile discholographic versatile disc
holographic versatile disc
 
week-22x
week-22xweek-22x
week-22x
 
week-16x
week-16xweek-16x
week-16x
 
ch8
ch8ch8
ch8
 
Intro Expert Systems test-me.co.uk
Intro Expert Systems test-me.co.ukIntro Expert Systems test-me.co.uk
Intro Expert Systems test-me.co.uk
 
ch17
ch17ch17
ch17
 
ch4
ch4ch4
ch4
 
week-7x
week-7xweek-7x
week-7x
 
week-9x
week-9xweek-9x
week-9x
 
week-14x
week-14xweek-14x
week-14x
 
AIRBORNE
AIRBORNEAIRBORNE
AIRBORNE
 
ch2
ch2ch2
ch2
 
ch3
ch3ch3
ch3
 
Entity Classes and Attributes
Entity Classes and AttributesEntity Classes and Attributes
Entity Classes and Attributes
 
week-20x
week-20xweek-20x
week-20x
 

Recently uploaded

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxLigayaBacuel1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 

Recently uploaded (20)

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Planning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptxPlanning a health career 4th Quarter.pptx
Planning a health career 4th Quarter.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 

week-10x

  • 1. /* 2’s complement of a number is obtained by scanning it from right to left and complementing all the bits after the first appearance of a 1. Thus 2’s complement of 11100 is 00100. Write a C program to find the 2’s complement of a binary number.*/ #include <stdio.h> #include<conio.h> void complement (char *a); void main() { char a[16]; int i; clrscr(); printf("Enter the binary number"); gets(a); for(i=0;a[i]!='0'; i++) { if (a[i]!='0' && a[i]!='1') { printf("The number entered is not a binary number. Enter the correct number"); exit(0); } } complement(a);
  • 2. getch(); } void complement (char *a) { int l, i, c=0; char b[16]; l=strlen(a); for (i=l-1; i>=0; i--) { if (a[i]=='0') b[i]='1'; else b[i]='0'; } for(i=l-1; i>=0; i--) { if(i==l-1) { if (b[i]=='0') b[i]='1'; else { b[i]='0'; c=1;
  • 3. } } else { if(c==1 && b[i]=='0') { b[i]='1'; c=0; } else if (c==1 && b[i]=='1') { b[i]='0'; c=1; } } } b[l]='0'; printf("The 2's complement is %s", b); }
  • 4. /* Write a C program to convert a Roman numeral to its decimal equivalent. */ #include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h> void main() { int *a,len,i,j,k; char *rom; clrscr(); printf("Enter the Roman Numeral:"); scanf("%s",rom); len=strlen(rom); for(i=0;i<len;i++)
  • 5. { 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; else { printf("nInvalid Value"); getch(); exit(0); } } k=a[len-1]; for(i=len-1;i>0;i--)
  • 6. { if(a[i]>a[i-1]) k=k-a[i-1]; else if(a[i]==a[i-1] || a[i]<a[i-1]) k=k+a[i-1]; } printf("nIts Decimal Equivalent is:"); printf("%d",k); getch(); }