Wednesday, August 26, 2015

C Program to Add Two Numbers


Q. – Write a C program to find the sum of given two numbers.

Ans:- Two numbers, says a and b, are given (input) and the result sum = a+b of two numbers are to be calculated.



/* Arithmetic Operators Addition */
#include <stdio.h>
int main()
{
    int a, b, sum;
    scanf("%d %d", &a, &b);
    sum = a+b;
    printf("%d", sum);
    return 0;

}

User- Friendly Program


/* Arithmetic Operators Addition – User friendly program */
#include<stdio.h>
int main()
{
    int a, b, sum;
    printf("\n Enter Value to A: ");
    scanf("%d", &a);
    printf("\n Enter Value to B: ");
    scanf("%d", &b);
    sum = a+b;
    printf("\n SUM = %d", sum);
    return 0;

}




Like it ? Share it.

Friday, August 14, 2015

C Program to find Remainder or Modulus of two numbers

Q. – Write a C program to find the Remainder of given two numbers.

Ans:- Two numbers, says a and b, are given (input) and the result remainder = a%b of two numbers are to be calculated.



/* Arithmetic Operators Remainder */
#include <stdio.h>
main()
{
    int a, b, remainder;
    scanf("%d %d", &a, &b);
    remainder = a%b;
    printf("%d", remainder);
    return 0;

}

User Friendly Program

/* Arithmetic Operators Remainder – User friendly program */
#include<stdio.h>
main()
{
    int a, b, remainder;
    printf("\n Enter Value to A: ");
    scanf("%d", &a);
    printf("\n Enter Value to B: ");
    scanf("%d", &b);
    remainder = a%b;
    printf("\n Remainder = %d", remainder);
    return 0;

}





Like it ? Share it.

Thursday, August 13, 2015

C Program to find division of two numbers


Q. – Write a C program to find the Division of given two numbers.

Ans:- Two numbers, says a and b, are given (input) and the result division = a/b of two numbers are to be calculated.



/* Arithmetic Operators Division */
#include <stdio.h>
main()
{
    int a, b, division;
    scanf("%d %d", &a, &b);
    division = a/b;
    printf("%d", division);
    return 0;

}

User Friendly Program


/* Arithmetic Operators Division – User friendly program */
#include<stdio.h>
main()
{
    int a, b, division;
    printf("\n Enter Value to A: ");
    scanf("%d", &a);
    printf("\n Enter Value to B: ");
    scanf("%d", &b);
    division = a/b;
    printf("\n Division = %d", division);
    return 0;

}





Like it ? Share it.

Wednesday, August 12, 2015

C Program to find Multiplication or Product of Two Numbers


Q. – Write a C program to find the Product of given two numbers.

Ans:- Two numbers, says a and b, are given (input) and the result product = a*b of two numbers are to be calculated.



/* Arithmetic Operators Product or Multiplication */
#include <stdio.h>
main()
{
    int a, b, product;
    scanf("%d %d", &a, &b);
    product = a*b;
    printf("%d", product);
    return 0;

}

User Friendly Program

/* Arithmetic Operators Product or Multiplication – User friendly program */
#include<stdio.h>
main()
{
    int a, b, product;
    printf("\n Enter Value to A: ");
    scanf("%d", &a);
    printf("\n Enter Value to B: ");
    scanf("%d", &b);
    product = a*b;
    printf("\n Product = %d", product);
    return 0;

}






Like it ? Share it.

Tuesday, August 11, 2015

C Program to Subtract two numbers


Q. – Write a C program to find the subtraction of given two numbers.

Ans:- Two numbers, says a and b, are given (input) and the result sub = a-b of two numbers are to be calculated.




/* Arithmetic Operators Subtraction */
#include <stdio.h>
main()
{
    int a, b, sub;
    scanf("%d %d", &a, &b);
    sub = a-b;
    printf("%d", sub);
    return 0;

}

User Friendly Program



/* Arithmetic Operators Subtraction – User friendly program */
#include<stdio.h>
main()
{
    int a, b, sub;
    printf("\n Enter Value to A: ");
    scanf("%d", &a);
    printf("\n Enter Value to B: ");
    scanf("%d", &b);
    sub = a-b;
    printf("\n Subtract = %d", sub);
    return 0;

}




Like it ? Share it.