0% found this document useful (0 votes)
13 views

Programming Basic Numerical

Uploaded by

diponkar2003
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Programming Basic Numerical

Uploaded by

diponkar2003
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Basic Programming Algorithm for Numerical Analysis

For Normal Sum with any two numbers:


#include<stdio.h>
main()
{
int a, b, sum;
printf("Enter the two numbers :");
scanf("%d %d", &a, &b);
sum=a+b;
printf("The sum is %d", sum);

For Two Known Numbers:


#include<stdio.h>
main()
{
int a=125, b=5, sum, div, mul, sub;
sum=a+b;
div=a/b;
mul=a*b;
sub=a-b;
printf("%d, %d, %d, %d", sum, div, mul, sub);

For Any Two Numbers in different Printf:

#include<stdio.h>
main()
{
int a, b, sum, div, mul, sub;
printf("Enter the two numbers :");
scanf("%d %d", &a, &b);
sum=a+b;
div=a/b;
mul=a*b;
sub=a-b;
printf("The summation is %d", sum);
printf("The division is %d", div);
printf("The multiplication is %d", mul);
printf("The substraction is %d", sub);

}
For Two Numbers and One PrintF:
#include<stdio.h>
main()
{
int a, b, sum, div, mul, sub;
printf("Enter the two numbers :");
scanf("%d %d", &a, &b);
sum=a+b;
div=a/b;
mul=a*b;
sub=a-b;
printf("The summation is %d, The division is %d, The multiplication is %d, The substraction is %d", sum, div, mul, sub);
}

*Write a C programme that checks wheather a given integer is positive or negative .

*
#include<stdio.h>
main()
{
int a;
printf("ENTER A NUMBER :");
scanf("%d", &a);
if(a<0)
printf("%d is Negative", a);
else
printf("%d is positive", a);

*When 0 is Zero

#include<stdio.h>
main()
{
int a;
printf("ENTER A NUMBER :");
scanf("%d", &a);
if(a<0)
printf("%d is Negative", a);
else if(a>0)
printf("%d is positive", a);
else
printf("Zero");

}
Odd Even
#include<stdio.h>
main()
{
int a;
printf("ENTER A NUMBER :");
scanf("%d",&a);
if(a%2==0)
printf("%d is even", a);
else
printf("%d is odd", a);

Find the maximum value between two numbers

#include<stdio.h>
main()
{
int a, b;
printf("Enter two numbers :");
scanf("%d %d", &a, &b);
if(a>b)
printf("%d is larger",a);
else if(a<b)
printf("%d is smaller", b);

Calculate Net amount with 5% vat

#include<stdio.h>
main()
{
float a, am;
printf("Enter a number :");
scanf("%f", &a);
am=(a+(a*0.05));
printf("The am is %f", am);

}
Calculate Route N and Power n
#include<stdio.h>
main()
{
float n, x, a, b;
printf("Enter two numbers :");
scanf("%f %f",&n, &x);
a=sqrt(n);
b=pow(n,x);
printf("The first value is %f,The second value is %f", a, b);

Forward Difference Table

#include<stdio.h>
main()
{
float x[20], y[20] [20];
int i, j, n;
/* Input Section */
printf("Enter number of data?\n");
scanf("%d", &n);
printf("Enter data:\n");
for(i = 0; i < n ; i++)
{
printf("x[%d]=", i);
scanf("%f", &x[i]);
printf("y[%d]=", i);
scanf("%f", &y[i] [0]);
}

/* Generating Forward Difference Table */


for(i = 1; i < n; i++)
{
for(j = 0; j < n-i; j++)
{
y[j] [i] = y[j+1] [i-1] - y[j] [i-1];
}
}
/* Displaying Forward Difference Table */
printf("\nFORWARD DIFFERENCE TABLE\n\n");
for(i = 0; i < n; i++)
{
printf("%0.2f", x[i]);
for(j = 0; j < n-i ; j++)
{
printf("\t%0.2f", y[i] [j]);
}
printf("\n");
}

return 0;
}

You might also like