Arithmetic Operators – Programs [Learn to code]

Prorams on Arithmetic Operators

  • 002. Write a program to accept values of two numbers and print their addition
    #include<stdio.h>
    #include<conio.h>
    main()
    {
     int a,b,c;
     clrscr();
     printf("Enter number 1: ");
     scanf("%d",&a);
     printf("Enter number 2: ");
     scanf("%d",&b);
     c=a+b;
     printf("Addition is   : %d",c);
     getch();
    }
  • 003. Write a program to accept values of two numbers and print their subtraction
     
    #include<stdio.h>
    #include<conio.h>
    main()
    {
     int a,b,c;
     clrscr();
     printf("Enter number 1: ");
     scanf("%d",&a);
     printf("Enter number 2: ");
     scanf("%d",&b);
     c=a-b;
     printf("Subtraction   : %d",c);
     getch();
    }
  • 004. Write a program to accept values of two numbers and print their multiplication in C language
    #include<stdio.h>
    #include<conio.h>
    main()
    {
     int a,b,c;
     clrscr();
     printf("Enter number 1: ");
     scanf("%d",&a);
     printf("Enter number 2: ");
     scanf("%d",&b);
     c=a*b;
     printf("Multiplication: %d",c);
     getch();
    }
  • 005. Write a program to accept values of two numbers and print their division in C language
    #include<stdio.h>
    #include<conio.h>
    main()
    {
     float a,b,c;
     clrscr();
     printf("Enter number 1: ");
     scanf("%f",&a);
     printf("Enter number 2: ");
     scanf("%f",&b);
     c=a/b;
     printf("Division is   : %f",c);
     getch();
    }
  • 006. Write a program to print area of a circle. A(circle)= 3.142 * R * R in C language
     
    #include<stdio.h>
    #include<conio.h>
    main()
    {
     float AREA,R;
     clrscr();
     printf("Enter Radius: ");
     scanf("%f",&R);
     AREA=3.14*R*R;
     printf("Area of the given is : %6.2f",AREA);
     getch();
    }
  • 007. Write a program to print area of a triangle A(Triangle)= 0.5 * B * H in C language
     
    #include<stdio.h>
    #include<conio.h>
    main()
    {
     float AREA,B,H;
     clrscr();
     printf("Enter Base & Height: ");
     scanf("%f%f",&B,&H);
     AREA=0.5*B*H;
     printf("Area of the given is : %6.2f",AREA);
     getch();
    }
  • 008. Write a program to print simple interest SI = (PNR)/100 in C language
    #include<stdio.h>
    #include<conio.h>
    main()
    {
     float SI,P,N,R;
     clrscr();
     printf("Enter values of P, N and R: ");
     scanf("%f%f%f",&P,&N,&R);
     SI=(P*N*R)/100;
     printf("Simple interest = : %6.2f",SI);
     getch();
    }
  • 009. Write a program to accept a number from user and print it’s square & cube in C language
    #include<stdio.h> 
    #include<conio.h>
    main()
    {
     int n, Square, Cube;
     clrscr();
     printf("Enter Number: ");
     scanf("%d",&amp;n);
     Square=n*n;
     Cube=n*n*n;
     printf("nSquare: %dnCube: %d",Square,Cube);
     getch();
    }
  • 010. Write a program to accept two values a & b and interchange their values in C language
    #include<stdio.h>
    #include<conio.h> 
    main()
    {
     int a, b, temp;
     clrscr();
     printf("Enter Numbers: ");
     scanf("%d%d",&a,&b);
     printf("nBefore Swapping..na=%d,b=%d",a,b); 
     temp=a;
     a=b;
     b=temp;
     printf("nAfter Swapping..na=%d,b=%d",a,b);
     getch();
    }
  • 011. Write a program to accept roll no and marks of 3 subjects of a student, Calculate total of 3 subjects and average in C language
    #include<stdio.h> 
    #include<conio.h>
    main()
    {
      int roll_no,m1,m2,m3,total;
      float average;
      clrscr();
      printf("Enter roll number : ");
      scanf("%d",&roll_no);
      printf("Enter marks 1 : "); 
      scanf("%d",&m1);
      printf("Enter marks 2 : ");
      scanf("%d",&m2);
      printf("Enter marks 3 : ");
      scanf("%d",&m3);
      total=m1+m2+m3;
      average=total/3.0;
      printf("nStudent Roll Number : %d",roll_no);
      printf("nMarks 1 : %d",m1);
      printf("nMarks 2 : %d",m2);
      printf("nMarks 3 : %d",m3);
      printf("nTotal : %d ",total);
      printf("nAverage : %f ",average);
      getch();
    }

011. Write a program to accept roll no and marks of 3 subjects of a student, Calculate total of 3 subjects and average in C language

#include<stdio.h> 
#include<conio.h>
main()
{
  int roll_no,m1,m2,m3,total;
  float average;
  clrscr();
  printf("Enter roll number : ");
  scanf("%d",&roll_no);
  printf("Enter marks 1 : "); 
  scanf("%d",&m1);
  printf("Enter marks 2 : ");
  scanf("%d",&m2);
  printf("Enter marks 3 : ");
  scanf("%d",&m3);
  total=m1+m2+m3;
  average=total/3.0;
  printf("\nStudent Roll Number : %d",roll_no);
  printf("\nMarks 1 : %d",m1);
  printf("\nMarks 2 : %d",m2);
  printf("\nMarks 3 : %d",m3);
  printf("\nTotal : %d ",total);
  printf("\nAverage : %f ",average);
  getch();
}

010. Write a program to accept two values a & b and interchange their values in C language

#include<stdio.h>
#include<conio.h> 
main()
{
 int a, b, temp;
 clrscr();
 printf("Enter Numbers: ");
 scanf("%d%d",&a,&b);
 printf("\nBefore Swapping..\na=%d,b=%d",a,b); 
 temp=a;
 a=b;
 b=temp;
 printf("\nAfter Swapping..\na=%d,b=%d",a,b);
 getch();
}

009. Write a program to accept a number from user and print it’s square & cube in C language

#include<stdio.h> 
#include<conio.h>
main()
{
 int n, Square, Cube;
 clrscr();
 printf("Enter Number: ");
 scanf("%d",&amp;n);
 Square=n*n;
 Cube=n*n*n;
 printf("\nSquare: %d\nCube: %d",Square,Cube);
 getch();
}

008. Write a program to print simple interest SI = (PNR)/100 in C language

#include<stdio.h>
#include<conio.h>
main()
{
 float SI,P,N,R;
 clrscr();
 printf("Enter values of P, N and R: ");
 scanf("%f%f%f",&P,&N,&R);
 SI=(P*N*R)/100;
 printf("Simple interest = : %6.2f",SI);
 getch();
}

007. Write a program to print area of a triangle A(Triangle)= 0.5 * B * H in C language

 
#include<stdio.h>
#include<conio.h>
main()
{
 float AREA,B,H;
 clrscr();
 printf("Enter Base & Height: ");
 scanf("%f%f",&B,&H);
 AREA=0.5*B*H;
 printf("Area of the given is : %6.2f",AREA);
 getch();
}

006. Write a program to print area of a circle. A(circle)= 3.142 * R * R in C language

 
#include<stdio.h>
#include<conio.h>
main()
{
 float AREA,R;
 clrscr();
 printf("Enter Radius: ");
 scanf("%f",&R);
 AREA=3.14*R*R;
 printf("Area of the given is : %6.2f",AREA);
 getch();
}

005. Write a program to accept values of two numbers and print their division in C language

#include<stdio.h>
#include<conio.h>
main()
{
 float a,b,c;
 clrscr();
 printf("Enter number 1: ");
 scanf("%f",&a);
 printf("Enter number 2: ");
 scanf("%f",&b);
 c=a/b;
 printf("Division is   : %f",c);
 getch();
}

004. Write a program to accept values of two numbers and print their multiplication in C language

#include<stdio.h>
#include<conio.h>
main()
{
 int a,b,c;
 clrscr();
 printf("Enter number 1: ");
 scanf("%d",&a);
 printf("Enter number 2: ");
 scanf("%d",&b);
 c=a*b;
 printf("Multiplication: %d",c);
 getch();
}

003. Write a program to accept values of two numbers and print their subtraction

 
#include<stdio.h>
#include<conio.h>
main()
{
 int a,b,c;
 clrscr();
 printf("Enter number 1: ");
 scanf("%d",&a);
 printf("Enter number 2: ");
 scanf("%d",&b);
 c=a-b;
 printf("Subtraction   : %d",c);
 getch();
}