Close Menu
Fsc Online | Online Notes, Educational News & Latest Government Job UpdatesFsc Online | Online Notes, Educational News & Latest Government Job Updates
  • Home
  • Notes
    • Online Courses
      • 12th Class
      • 11th Class
      • 10th Class
      • 9th Class
  • Jobs
    • PPSC Jobs
    • SPSC Jobs
    • Punjab Police Jobs
  • Education News
  • E-Books
    • Punjab Text Book (PTB)
  • Model Papers
  • Results
  • Admissions
  • Colleges
  • More
    • Paper Schemes
    • Date Sheets
    • Guess Papers
    • Roll No Slips
Facebook X (Twitter)
Trending
  • NADRA Islamabad Announced Latest April Jobs 2024
  • TEVTA Sargodha Announced Instructor / Clerk Jobs 2024
  • BPSC Announced Latest Jobs Through Advertisement no. 03/2024
  • All Subjects 12th Class Paper Scheme 2024 | Punjab Board
  • 12th Class Computer Science Paper Scheme 2024 Punjab Board
  • 9th Class Pakistan Studies Guess Papers 2024 Punjab Board
  • 12th Class Biology Paper Pairing Scheme 2024 Punjab Board
  • Physics 12th Class Paper Scheme 2024 Punjab Board
Fsc Online | Online Notes, Educational News & Latest Government Job UpdatesFsc Online | Online Notes, Educational News & Latest Government Job Updates
  • Home
  • Notes
    • Online Courses
      • 12th Class
      • 11th Class
      • 10th Class
      • 9th Class
  • Jobs
    • PPSC Jobs
    • SPSC Jobs
    • Punjab Police Jobs
  • Education News
  • E-Books
    • Punjab Text Book (PTB)
  • Model Papers
  • Results
  • Admissions
  • Colleges
  • More
    • Paper Schemes
    • Date Sheets
    • Guess Papers
    • Roll No Slips
Fsc Online | Online Notes, Educational News & Latest Government Job UpdatesFsc Online | Online Notes, Educational News & Latest Government Job Updates
Home » Computer Science » C Language » C Programs » [C/C++] Program to Convert Decimal Number in Binary
C Language

[C/C++] Program to Convert Decimal Number in Binary

October 2, 2015Updated:September 13, 2018No Comments1 Min Read
WhatsApp Facebook Twitter Pinterest LinkedIn Tumblr Email

A simple c and c++ program to convert a decimal number into binary number system.
C/C++ program to convert base ten number system into base two number system or 0’s and 1’s format.
Program is simple and it just convert simple integers decimal into binary. This will not work for floating values and negative values.

C Code

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

using namespace std; 

void main()
{
 int a=1,sum=0,x;
 
 printf("Enter a Decimel Number: ");
 scanf("%d", &x);
 int num=x;
 
 do
 {
 sum+=(x%2)*a;
 x=x/2;
 a=a*10;
 }
 while(x!=0);
 
 printf("Binary of %d is: %d",num ,sum);
 
 getche();
}

C++ Code

#include <iostream>

using namespace std; 

int main()
{
 int a=1,sum=0,x;
 
 cout << "Enter a Decimel Number: ";
 cin >> x;
 int num=x;
 
 do
 {
 sum+=(x%2)*a;
 x=x/2;
 a=a*10;
 }
 while(x!=0);
 
 cout << "Binary of " << num << " is: " << sum;
}

Output:

program-to-convert-decimal-number-in-binary-number

Other Related Search Terms

  1. C++ program to convert base 10 number system in base 2 number system
  2. C program to convert base 10 number system in base 2 number system
  3. C++ program to convert decimal into binary.
  4. C program to convert decimal into binary

c programs computer science 2nd year cpp programs Online Course
Share. WhatsApp Facebook Twitter Pinterest LinkedIn Tumblr Email
Khurram Farooq
  • Website
  • Facebook
  • X (Twitter)

I'm a full-stack developer, specializing in the PHP, JS, Wordpress, MEAN Stack, MERN Stack & Django. I hold a high standard of quality in everything that I do.

Related Posts

How to do Exponents in Java – 3 Different Methods

January 12, 2020

Different Types of Processors And Their Features

January 12, 2020

Biology 1st Year Guess Paper 2018 Punjab Board

May 28, 2018
Leave A Reply Cancel Reply

SEARCH
ADVERTISEMENT
STAY WITH US
  • Facebook
  • Twitter
  • Instagram
LATEST JOBS

NADRA Islamabad Announced Latest April Jobs 2024

April 4, 2024

TEVTA Sargodha Announced Instructor / Clerk Jobs 2024

April 4, 2024

BPSC Announced Latest Jobs Through Advertisement no. 03/2024

April 4, 2024
LATEST NOTES

All Subjects 12th Class Paper Scheme 2024 | Punjab Board

April 4, 2024

12th Class Computer Science Paper Scheme 2024 Punjab Board

April 4, 2024

9th Class Pakistan Studies Guess Papers 2024 Punjab Board

April 4, 2024
RECENT POSTS

NADRA Islamabad Announced Latest April Jobs 2024

April 4, 2024

TEVTA Sargodha Announced Instructor / Clerk Jobs 2024

April 4, 2024

BPSC Announced Latest Jobs Through Advertisement no. 03/2024

April 4, 2024

All Subjects 12th Class Paper Scheme 2024 | Punjab Board

April 4, 2024
TRENDING THIS WEEK

PEC SBA 2023 Model Paper for Grades 03-08 [Download PDF]

December 16, 2022

Notification Regarding the Revised Standard Pay packages for Project (PPS) Posts

August 4, 2022

KU Announces Online BA/MA & B.COM Degree Programs 2023

July 27, 2023
ABOUT US
ABOUT US

Notes, Guess Papers, Old Papers, Jobs, Admissions, Results, Datasheets and everything else that falls into the wide world of education & careers. For any assist and query please contact us.

Home · About Us · Team · Contact · Advertise · DMCA Policy · Cookies Policy · Privacy Policy
© 2013-2026 Powered By FScOnline - Made with ♥ for the students of Pakistan.

Type above and press Enter to search. Press Esc to cancel.

Go to mobile version
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.