Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to convert number in 9's complement

Posted By: Niamh Hughes     Category: C Programming     Views: 9497

Write a program to convert number in 9's complement.

Code for Program to convert number in 9's complement in C Programming

#include<stdio.h>
#include<conio.h>

void main()
{
    int n1,n2,com=0,i,j,com9=0,n,m;
    clrscr();
        printf("\n\n\t\t YOU ENTER VALUE IN DECIMAL MEANS (0-9)\n\n");
        printf("\n PLEASE ENTER THE VALUE OF N1:= ");
        scanf("%d",&n1);
        printf("\n PLEASE ENTER THE VALUE OF N2:= ");
        scanf("%d",&n2);
        for(i=1,j=9;i<n2;i=i*10,j=j+(9*i))
        {
            n=i;
            m=j;
        }
            printf("\nI=%d \n j=%d",i,j);
            printf("\nn=%d \n m=%d",n,m);
            com=m-n2;
            printf("\n IT IS VALUE OF COMPLEMENTED %d",com);
        com9=n1+com;
        if(com9>m)
            com9=com9-i+1;

        printf("\n\n\tIT IS THE VALUE OF 9`S COMPLEMENT %d",com9);


        getch();

}
  
Share: 


Didn't find what you were looking for? Find more on Program to convert number in 9's complement Or get search suggestion and latest updates.

Niamh Hughes
Niamh Hughes author of Program to convert number in 9's complement is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!