Showing posts with label Multiplication. Show all posts
Showing posts with label Multiplication. Show all posts

How to Write a C program to perform basic math operations on two input whole numbers. The basic operations are addition, subtraction, multiplication, integer division, real division, and modulus.

Write a C program to perform basic math operations on two input whole numbers. The basic operations are addition, subtraction, multiplication, integer division, real division, and modulus (%)



  1. //Write a C program to perform basic math operations on two input whole numbers. The basic operations are addition, subtraction, multiplication, integer division, real division, and modulus (%).
  2. #include<iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x,y;
  7.     cin>>x>>y;
  8.     cout<<"Addition:"<<x+y<<endl;
  9.     cout<<"Subtraction:"<<x-y<<endl;
  10.     cout<<"Multiplication:"<<x*y<<endl;
  11.     cout<<"Integer division:"<<x/y<<endl;
  12.     cout<<"Real division:"<<(float)x/y<<endl;
  13.     cout<<"Modulus"<<x%y;
  14. }

C Program To Generate Multiplication Table

How to write a C Program to generate Multiplication Table in C Programming Language ?


Solution For C Program:

/*C Program To Generate Multiplication Table*/

#include<stdio.h>
void main()
{
int num, ctr;
printf("\nEnter Number for the Table : ");
scanf("%d", &num);
printf("\nNow Printing the Table...\n");
for(ctr = 1; ctr <= 10; ctr++)
printf("%d\t*\t%d\t=\t%d\n", num, ctr, num * ctr);
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Program to Find The Product Of Two Numbers Without Multiplication Operator.

How to write a C Program to find the product of two numbers without Multiplication Operator in C Programming Language ?

Solution for C Program: 

/*C Program to Find The Product Of Two Numbers Without Multiplication Operator.*/
#include<stdio.h>
void main()
{
int x, y, I, sum;
printf("\nEnter any two numbers : ");
scanf("%d%d", &x, &y);
I = 1;
sum = 0;
while(I <= y)
{
sum += x;
I++;
}
printf("\nThe Product of %d and %d is %d.", x, y, sum);
}

You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

Sequential Matrix Multiplication C Program

How to write a C Program to Sequential Matrix Multiplication in C Programming Language ?


Solution:
/*sequential matrix multiplication*/