Description

Primary Arithmetic program in c programming language.

#include<stdio.h>

long carryAddOfNumber(long n1, long n2){
    long x, y, carry=0, carryCount=0;
    while(1){
        x = n1 % 10;
        y = n2 % 10;
        n1 = n1 / 10;
        n2 = n2 / 10;
        
        if((x + y + carry)>=10){
            carryCount++;
            carry = 1;
        }
        else{
            carry = 0;
        }
        
        if(n1 == 0 && n2 == 0)
        {
            break;
        }
    }
    return carryCount;
}

int main(){
    long n1, n2, carry;

    while(1){
            printf("Enter the number1 and number2 : \n");
            scanf("%ld %ld", &n1, &n2);
        if(n1 == 0 && n2 == 0){
            break;
        }
        carry = carryAddOfNumber(n1, n2);
        
        if(carry == 0){
            printf("No Carry Operation\n");
        }
        else{
            printf("%ld Carry Operation\n", carry);
        }
    }
    return 0;
}

Primary Arithmetic program in c programming language.

#include<iostream>

using namespace std;

long carryAddOfNumber(long n1, long n2){
    long x, y, carry=0, carryCount=0;
    while(1){
        x = n1 % 10;
        y = n2 % 10;
        n1 = n1 / 10;
        n2 = n2 / 10;
        
        if((x + y + carry)>=10){
            carryCount++;
            carry = 1;
        }
        else{
            carry = 0;
        }
        
        if(n1 == 0 && n2 == 0)
        {
            break;
        }
    }
    return carryCount;
}

int main(){
    long n1, n2, carry;

    while(1){
            cout<<"Enter the num1 and num2 : \n";
            cin>>n1>>n2;
        if(n1 == 0 && n2 == 0){
            break;
        }
        carry = carryAddOfNumber(n1, n2);
        
        if(carry == 0){
            cout<<"No Carry Operation\n";
        }
        else{
            cout<<carry<<" Carry Operation\n";
        }
    }
    return 0;
}

Output :

Enter the num1 and num2 : 
781
651
2 Carry Operation

Comments

Login is mandatory to comment Please login

Recommended Posts

Automorphic Number | C programming language | @lapmos

An automorphic number is a number that has the same digit at the end of the square as the given number is an automorphic number. For Example : 25 is a Automorphic Number.

9 basic program in cpp programming language | @lapmos

In this post we write the 9 basic program in c programming language which is based the basic understanding of c++ programming language.

Spy Number | c programming

Today we are going to write a program which is to check if given number is spy or not and yes the most important thing is what is spy number, you will get the answer of all these on this blog.

Display Name of the month by accepting digit of the month | c programming

We will print the month name from the month number given by the user which will give us the user input. For Example : User Entered 5 then print

Happy Numbers | with Example And Programs

Replace the number by the sum of the squares of its digits, and repeat the process. At the end, if the number is equals to 1 then it is a Happy Number, or it loops endlessly in a cycle that does not include 1 (if it is not a happy number then this process will end at 4).

Sunny Number in programming

A number is a sunny number. If 1 is added to that number and the square root of it becomes a whole number.