C C++ program to convert binary to decimal

C C++ program to convert binary to decimal

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

C और C++ दोनों भाषाओं में महत्वपूर्ण अंतर क्या है जानने के लिए देखें—C vs C++

Procedure Oriented Programming (POP) और Object Oriented Programming (OOP) में अंतर जानने के लिए देखें—POP vs OOP

Flowchart to convert binary to decimal

Binary to decimal conversion flowchart

C program to convert binary to decimal

#include<stdio.h>
int main()
{
    int binary, decimal=0, digit, base=1;
    printf("Enter binary number: ");
    scanf("%d",&binary);
    while(binary!=0)
    {
        digit=binary%10;
        decimal=digit*base+decimal;
        base=base*2;
        binary=binary/10;
    }
    printf("Decimal number = %d",decimal);
    return 0;
}

C++ program to convert binary to decimal

#include<iostream>
using namespace std;
int main()
{
    int binary, decimal=0, digit, base=1;
    cout<<"Enter binary number: ";
    cin>>binary;
    while(binary!=0)
    {
        digit=binary%10;
        decimal=digit*base+decimal;
        base=base*2;
        binary=binary/10;
    }
    cout<<"Decimal number = "<<decimal;
    return 0;
}

Output of C C++ program to convert binary to decimal

Enter binary number: 110100
Decimal number = 52
Enter binary number: 1001110
Decimal number = 78

More looping and Iteration programs in C and C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Find power of given number
  8. Generate multiplication table of given number
  9. HCF and LCM of two numbers
  10. Generating Fibonacci series
  11. Checking prime number
  12. Generating series of prime numbers
  13. Sum of digits of given number
  14. Reverse of digits of given number
  15. Checking palindrome number
  16. Checking Armstrong number
  17. Generating series of Armstrong numbers
  18. Convert binary to decimal
Share it to:

C C++ program to convert decimal to binary

C C++ program to convert decimal to binary

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

Procedure Oriented Programming (POP) और Object Oriented Programming (OOP) में अंतर जानने के लिए देखें—POP vs OOP

Flowchart to convert decimal to binary

Decimal to binary conversion flowchart

C program to convert decimal to binary

#include<stdio.h>
int main()
{
    int decimal, binary=0, digit, base=1;
    printf("Enter decimal number: ");
    scanf("%d",&decimal);
    while(decimal!=0)
    {
        digit=decimal%2;
        binary=digit*base+binary;
        base=base*10;
        decimal=decimal/2;
    }
    printf("Binary number = %d",binary);
    return 0;
}

C++ program to convert decimal to binary

#include<iostream>
using namespace std;
int main()
{
    int decimal, binary=0, digit, base=1;
    cout<<"Enter decimal number: ";
    cin>>decimal;
    while(decimal!=0)
    {
        digit=decimal%2;
        binary=digit*base+binary;
        base=base*10;
        decimal=decimal/2;
    }
    cout<<"Binary number = "<<binary;
    return 0;
}

Output of C C++ program to convert decimal to binary

Enter decimal number: 52
Binary number = 110100
Enter decimal number: 78
Binary number = 1001110 

More iterative logic based programs in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Find power of given number
  8. Generate multiplication table of given number
  9. HCF and LCM of two numbers
  10. Generating Fibonacci series
  11. Checking prime number
  12. Generating series of prime numbers
  13. Sum of digits of given number
  14. Reverse of digits of given number
  15. Checking palindrome number
  16. Checking Armstrong number
  17. Generating series of Armstrong numbers
  18. Convert binary to decimal
Share it to:

C C++ program to generate series of Armstrong numbers

C C++ program to generate series of Armstrong numbers

C Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C

C और C++ दोनों भाषाओं में महत्वपूर्ण अंतर क्या है जानने के लिए देखें—C vs C++

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

Flowchart to generate series of Armstrong numbers

Generate series of armstrong numberrs upto n flowchart

C program to generate series of Armstrong numbers

#include<stdio.h>
int main()
{
    int num=1,rem,sum,org,n;
    printf("Enter n: ");
    scanf("%d",&n);
    while(num<=n)
    {
        org=num;
        sum=0;
        while(num!=0)
        {
            rem=num%10;
            sum=sum+rem*rem*rem;
            num=num/10;
        }
        if(sum==org)
        {
            printf("%d\n",sum);
        }
        num=org+1;
    }
    return 0;
}

C++ program to generate series of Armstrong numbers

#include<iostream>
using namespace std;
int main()
{
    int num=1,rem,sum,org,n;
    cout<<"Enter n: ";
    cin>>n;
    while(num<=n)
    {
        org=num;
        sum=0;
        while(num!=0)
        {
            rem=num%10;
            sum=sum+rem*rem*rem;
            num=num/10;
        }
        if(sum==org)
        {
            cout<<sum<<"\n";
        }
        num=org+1;
    }
    return 0;
}

Output of C C++ program to generate series of Armstrong numbers

Enter n: 200
1
153
Enter n: 500
1
153 
370
371
407

More iteration logic programs in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Find power of given number
  8. Generate multiplication table of given number
  9. HCF and LCM of two numbers
  10. Generating Fibonacci series
  11. Checking prime number
  12. Generating series of prime numbers
  13. Sum of digits of given number
  14. Reverse of digits of given number
  15. Checking palindrome number
  16. Checking Armstrong number
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

C C++ program to check Armstrong number

C C++ program to check Armstrong number

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

Procedure Oriented Programming (POP) और Object Oriented Programming (OOP) में अंतर जानने के लिए देखें—POP vs OOP

Object Oriented Programming (OOP) की विभिन्न अवधारणाओं को जानने के लिए देखें—Concepts of OOP

Flowchart to check Armstrong number

Check whether given number is armstrong or not flowchart

C program to check Armstrong number

#include<stdio.h>
int main()
{
    int num,rem,sum=0,org;
    printf("Enter a number: ");
    scanf("%d",&num);
    org=num;
    while(num!=0)
    {
        rem=num%10;
        sum=sum+rem*rem*rem;
        num=num/10;
    }
    if(sum==org)
    {
        printf("Armstrong");
    }
    else
    {
        printf("Not an Armstrong");
    }
    return 0;
}

C++ program to check Armstrong number

#include<iostream>
using namespace std;
int main()
{
    int num,rem,sum=0,org;
    cout<<"Enter a number: ";
    cin>>num;
    org=num;
    while(num!=0)
    {
        rem=num%10;
        sum=sum+rem*rem*rem;
        num=num/10;
    }
    if(sum==org)
    {
        cout<<"Armstrong";
    }
    else
    {
        cout<<"Not an armstrong";
    }
    return 0;
}

Output of C C++ program to check Armstrong number

Enter a number: 153
Armstrong
Enter a number: 121
Not an armstrong 

More looping programs in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Find power of given number
  8. Generate multiplication table of given number
  9. HCF and LCM of two numbers
  10. Generating Fibonacci series
  11. Checking prime number
  12. Generating series of prime numbers
  13. Sum of digits of given number
  14. Reverse of digits of given number
  15. Checking palindrome number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

C C++ program to check palindrome number

C C++ program to check palindrome number

Switch statement और multibranching statements के बारे में अधिक जानने के लिए देखें—Switch statements in C

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

Unconditional branching statements के बारे में अधिक जानकारी के लिए देखें— Break, Continue and Goto in C

Flowchart to check palindrome number

Check whether given number is palindrome or not flowchart

C program to check palindrome number

#include<stdio.h>
int main()
{
    int num,rem,rev=0,org;
    printf("Enter a number: ");
    scanf("%d",&num);
    org=num;
    while(num!=0)
    {
        rem=num%10;
        rev=rev*10+rem;
        num=num/10;
    }
    if(rev==org)
    {
        printf("Palindrome");
    }
    else
    {
        printf("Not a palindrome");
    }
    return 0;
}

C++ program to check palindrome number

#include<iostream>
using namespace std;
int main()
{
    int num,rem,rev=0,org;
    cout<<"Enter a number: ";
    cin>>num;
    org=num;
    while(num!=0)
    {
        rem=num%10;
        rev=rev*10+rem;
        num=num/10;
    }
    if(rev==org)
    {
        cout<<"Palindrome";
    }
    else
    {
        cout<<"Not a palindrome";
    }
    return 0;
}

Output of C C++ program to check palindrome number

Enter a number: 5665
Palindrome
Enter a number: 6438
Not a palindrome 

Other looping based programs in C and C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Find power of given number
  8. Generate multiplication table of given number
  9. HCF and LCM of two numbers
  10. Generating Fibonacci series
  11. Checking prime number
  12. Generating series of prime numbers
  13. Sum of digits of given number
  14. Reverse of digits of given number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

C C++ program to find reverse of digits of given number

C C++ program to find reverse of digits of given number

C++ Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C++

Procedure Oriented Programming (POP) और Object Oriented Programming (OOP) में अंतर जानने के लिए देखें—POP vs OOP

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

Flowchart to find reverse of digits of given number

Reverse of digits given number flowchart

C program to find reverse of digits of given number

#include<stdio.h>
int main()
{
    int num,rem,rev=0;
    printf("Enter a number: ");
    scanf("%d",&num);
    while(num!=0)
    {
        rem=num%10;
        rev=rev*10+rem;
        num=num/10;
    }
    printf("Reverse of digits = %d",rev);
    return 0;
}

C++ program to find reverse of digits of given number

#include<iostream>
using namespace std;
int main()
{
    int num,rem,rev=0;
    cout<<"Enter a number: ";
    cin>>num;
    while(num!=0)
    {
        rem=num%10;
        rev=rev*10+rem;
        num=num/10;
    }
    cout<<"Reverse of digits = "<<rev;
    return 0;
}

Output of C C++ program to find reverse of digits of given number

Enter a number: 639
Reverse of digits = 936
Enter a number: 1234
Reverse of digits = 4321

Other similar programs in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Find power of given number
  8. Generate multiplication table of given number
  9. HCF and LCM of two numbers
  10. Generating Fibonacci series
  11. Checking prime number
  12. Generating series of prime numbers
  13. Sum of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

C C++ program to find sum of digits of given number

C C++ program to find sum of digits of given number

C Language में उपलब्ध Operators और इनके विभिन्न प्रकारो को जानने के लिए देखें—Operators in C

C-Language में Operator Precedence और Associativity Rule क्या होता है जानने के लिए देखें— Precedence and Associativity in C

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

Flowchart to find sum of digits of given number

Sum of digits of given number flowchart

C program to find sum of digits of given number

#include<stdio.h>
int main()
{
    int num,rem,sum=0;
    printf("Enter a number: ");
    scanf("%d",&num);
    while(num!=0)
    {
        rem=num%10;
        sum=sum+rem;
        num=num/10;
    }
    printf("Sum of digits = %d",sum);
    return 0;
}

C++ program to find sum of digits of given number

#include<iostream>
using namespace std;
int main()
{
    int num,rem,sum=0;
    cout<<"Enter a number: ";
    cin>>num;
    while(num!=0)
    {
        rem=num%10;
        sum=sum+rem;
        num=num/10;
    }
    cout<<"Sum of digits = "<<sum;
    return 0;
}

Output of C C++ program to find sum of digits of given number

Enter a number: 472
Sum of digits = 13
Enter a number: 281
Sum of digits = 11 

Similar looping and Iterative programs in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Find power of given number
  8. Generate multiplication table of given number
  9. HCF and LCM of two numbers
  10. Generating Fibonacci series
  11. Checking prime number
  12. Generating series of prime numbers
  13. Reverse of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

C C++ program to generate series of prime numbers

C C++ program to generate series of prime numbers

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

C Language में character set क्या होता है जानने के लिए देखें—Character set of C

C Language में Token क्या होता है जानने के लिए देखें—Tokens in C

Flowchart to generate series of prime numbers

Generating prime numbers upto n flowchart

C program to generate series of prime numbers

#include<stdio.h>
int main()
{
    int num=1, c=2, n;
    char prime='t';
    printf("Enter n: ");
    scanf("%d",&n);
    while(num<=n)
    {
        c=2;
        prime='t';
        while(c<num)
        {
            if(num%c==0)
            {
                prime='f';
                break;
            }
            c++;
        }
        if(prime=='t')
        {
            printf("%d\n",num);
        }
        num++;
    }
    return 0;
}

C++ program to generate series of prime numbers

#include<iostream>
using namespace std;
int main()
{
    int num=1, c=2, n;
    char prime='t';
    cout<<"Enter n: ";
    cin>>n;
    while(num<=n)
    {
        c=2;
        prime='t';
        while(c<num)
        {
            if(num%c==0)
            {
                prime='f';
                break;
            }
            c++;
        }
        if(prime=='t')
        {
            cout<<num<<"\n";
        }
        num++;
    }
    return 0;
}

Output of C C++ program to generate series of prime numbers

Enter n: 10
1
2
3
5
7
Enter n: 20
1
2
3
5
7 
11
13
17
19

Some most common looping programs in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Find power of given number
  8. Generate multiplication table of given number
  9. HCF and LCM of two numbers
  10. Generating Fibonacci series
  11. Checking prime number
  12. Sum of digits of given number
  13. Reverse of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

Write a C C++ program to check entered number is prime or not

Write a C C++ program to check entered number is prime or not

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

Unconditional branching statements के बारे में अधिक जानकारी के लिए देखें— Break, Continue and Goto in C

Flowchart to check entered number is prime or not

Checking whether given number is prime or not flowchart

C program to check entered number is prime or not

#include<stdio.h>
int main()
{
    int num, c=2;
    char prime='t';
    printf("Enter a number: ");
    scanf("%d",&num);
    while(c<num)
    {
        if(num%c==0)
        {
            prime='f';
            break;
        }
        c++;
    }
    if(prime=='t')
    {
        printf("Prime number");
    }
    else
    {
        printf("Not a prime number");
    }
    return 0;
}

C++ program to check entered number is prime or not

#include<iostream>
using namespace std;
int main()
{
    int num, c=2;
    char prime='t';
    cout<<"Enter a number: ";
    cin>>num;
    while(c<num)
    {
        if(num%c==0)
        {
            prime='f';
            break;
        }
        c++;
    }
    if(prime=='t')
    {
        cout<<"Prime number";
    }
    else
    {
        cout<<"Not a prime number";
    }
    return 0;
}

Output of C C++ program to check entered number is prime or not

Enter a number: 5
Prime number
Enter a number: 10
Not a prime number

Other programs using while for and do while loops in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Find power of given number
  8. Generate multiplication table of given number
  9. HCF and LCM of two numbers
  10. Generating Fibonacci series
  11. Generating series of prime numbers
  12. Sum of digits of given number
  13. Reverse of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to:

Write a C C++ program to generate Fibonacci series

Write a C C++ program to generate Fibonacci series

C के विभिन्न control statements को जानने के लिए देखें— Control statements in C

If statement और decision making statements के बारे में अधिक जानने के लिए देखें— If statements in C

Looping और iterative statements के बारे में और अधिक जानने के लिए देखें— Looping statements in C

Flowchart to generate Fibonacci series

Fibonacci series upto n flowchart

C program to generate Fibonacci series

#include<stdio.h>
int main()
{
    int a=0,b=1,c=1,n;
    printf("Enter n: ");
    scanf("%d",&n);
    printf("%d\n",a);
    printf("%d\n",b);
    while(c<=n)
    {
        printf("%d\n",c);
        a=b;
        b=c;
        c=a+b;
    }
    return 0;
}

C++ program to generate Fibonacci series

#include<iostream>
using namespace std;
int main()
{
    int a=0,b=1,c=1,n;
    cout<<"Enter n: ";
    cin>>n;
    cout<<a<<"\n";
    cout<<b<<"\n";
    while(c<=n)
    {
        cout<<c<<"\n";
        a=b;
        b=c;
        c=a+b;
    }
    return 0;
}

Output of C C++ program to generate Fibonacci series

Enter n: 10
0
1
1
2
3
5
8
Enter n: 30
0
1
1
2
3
5
8 
13
21

Repetition logic based programs in C C++

  1. Generate series of natural numbers (while, for, do while)
  2. Generate series of natural numbers and their sum
  3. Generate series of odd numbers and find their sum
  4. Generate series of even numbers and find their sum
  5. Generate table of given number
  6. Find factorial of given number
  7. Find power of given number
  8. Generate multiplication table of given number
  9. HCF and LCM of two numbers
  10. Checking prime number
  11. Generating series of prime numbers
  12. Sum of digits of given number
  13. Reverse of digits of given number
  14. Checking palindrome number
  15. Checking Armstrong number
  16. Generating series of Armstrong numbers
  17. Convert decimal to binary
  18. Convert binary to decimal
Share it to: