Saturday 13 April 2019

how use Arithmetic operations in programming c


 how use Arithmetic operations in programming c

1.how two add two integers constant number in programming c.
2.Learn how to add two integers variable value in programming c which values are enter by user at run time.
3.how to add three integer number
4.how to add three float number
5.how to subtract two integer number and float number
6.how to multiply two or more number
7.how to divided two number
8.how to fetch remainder


1.how two add two integers constant number in programming c.


integer value mean 1 to 100 negative and positive number when you add constant value mean fixed value at execution time.
constant value never changed at run time for example value of pi=3.14 or value of gravitational force(g=9.8)

Now we take two fixed value
like n1=10 and n2=3 now calculate
sum of n1+n2 in programming c.
//LEARN HOW TO ADD TWO CONSTANT VALUE IN PROGRAMMING C.
#include<stdio.h>
#include<conio.h>
void main()
{
int n1=6;
int n2=8;
int sum;
clrscr();
sum=n1+n2;
printf("Sum of n1=%d and n2=%d Sum=%d",n1,n2,sum);
getch();
}

2.Learn how to add two integers variable value in programming c which values are enter by user at run time.


solution:
Firstly, assume two variable n1 and n2 whose values enter by user at run time, then assume another variable sum that
equal to n1+n2
now write c source code program as like this.


//Learn how to add two number in programming c
#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,sum;
clrscr();
printf("Enter any two integer number\n");
scanf("%d%d",&n1,&n2);
sum=n1+n2;
printf("Sum of number n1=%d \n n2=%d\n sum=%d",n1,n2,sum);
getch();
}

3.how to add three integer number

Solution:
Frist asume three integer number a,b, c,and let a total intetger to put equal of a+b+c where
A,b,c,total are integer variables that value are changeable at run time.
Now write source code of c program
//learn how to addition  three  integer numbers in programs  c
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,total;
printf(“ENTER THE VALUE OF VARIABLE A=\n”);
scanf(“%d”,&a);
printf(“ENTER THE VALUE OF VARIABLE B=\n”);
scanf(“%d”,&b);
printf(“ENTER THE VALUE OF VARIABLE C=\n”);
scanf(“%d”,&c);
total=a+b+c;
printf(“Numbers\n”);
printf(“A=%d”,a\n”);
printf(“B=%d”,b\n”);
printf(“C=%d”,c\n”);
printf(“Total=%d”,tatal);
getch();
}




4.how to add three float number

Solution:
Frist asume three float number a,b, c,and let a total float to put equal of a+b+c where
A,b,c,total are float variables that value are changeable at run time.
Now write source code of c program
//learn how to addition  three  float numbers in programs  c
#include<stdio.h>
#include<conio.h>
void main()
{
float a,b,c,total;
printf(“ENTER THE VALUE OF VARIABLE A=\n”);
scanf(“%f”,&a);
printf(“ENTER THE VALUE OF VARIABLE B=\n”);
scanf(“%f”,&b);
printf(“ENTER THE VALUE OF VARIABLE C=\n”);
scanf(“%f”,&c);
total=a+b+c;
printf(“Numbers\n”);
printf(“A=%f”,a\n”);
printf(“B=%f”,b\n”);
printf(“C=%f”,c\n”);
printf(“Total=%f”,tatal);
getch();
}



5.how to subtract two integer number and float number

Solution:
Fristly assume two integer variable a and b and then assume two float vriable x and y .
Now let two  variable result1 and result2 one is integer  and other is float
//learn how to subastracts value  in prograing c
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,result1;
float x,y,result 2;
printf(“ENTER THE VALUE OF A AND B\n”);
scanf(“%d%d”,&a,&b);
printf(“ENTER THE VALUE OF X AND Y\n”);
scanf(“%f%f”,&x,&y);
result1=a+b;
reesult2=x+y;
printf(“diffrace of a and b=%d\n”,result1);
printf(“diffrance of x and y=%f\n”,result2);
getch();
}


6.how to multiply two or more number

Solution:
Firstly assume all variable which want to multiply lik a,b,c.
now take a variable result to equal multiple result. then write source code as like.
#include<stdio.h>

#include<conio.h>
void main()
{
int a,b,c, result;

printf(“ENTER THE VALUE OF A AND B,C\n”);
scanf(“%d%d%d”,&a,&b,&c);

result1=a*b*c;

printf(“multiply of a and b,c=%d\n”,result);

getch();
}

7.how to divided two number?

solution:

Firstly, assume two variable n1 and n2 whose values enter by user at run time, then assume another variable div that
equal to n1/n2
now write c source code program as like this.

//Learn how to divided two number in programming c
#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,div;
clrscr();
printf("Enter any two integer number\n");
scanf("%d%d",&n1,&n2);
div=n1/n2;
printf("divided of number n1=%d \n n2=%d\n div=%d",n1,n2,div);
getch();
}


8.how to fetch remainder



solution:


Firstly, assume two variable n1 and n2 whose values enter by user at run time, then assume another variable rem that
equal to n1%n2
now write c source code program as like this.
//Learn how to take remainder two number in programming c
#include<stdio.h>
#include<conio.h>
void main()
{
int n1,n2,rem;
clrscr();
printf("Enter any two integer number\n");
scanf("%d%d",&n1,&n2);
rem=n1%n2;
printf("remof number n1=%d \n n2=%d\n rem=%d",n1,n2,rem);
getch();
}

0 comments:

Post a Comment