Wednesday, July 25, 2018

Excel- Create Sheet from List

Sub AddSheets()
'Updateby Extendoffice 20161215
    Dim xRg As Excel.Range
    Dim wSh As Excel.Worksheet
    Dim wBk As Excel.Workbook
    Set wSh = ActiveSheet
    Set wBk = ActiveWorkbook
    Application.ScreenUpdating = False
    For Each xRg In wSh.Range("A1:A30")
        With wBk
            .Sheets.Add after:=.Sheets(.Sheets.Count)
            On Error Resume Next
            ActiveSheet.Name = xRg.Value
            If Err.Number = 1004 Then
              Debug.Print xRg.Value & " already used as a sheet name"
            End If
            On Error GoTo 0
        End With
    Next xRg
    Application.ScreenUpdating = True
End Sub

Tuesday, August 2, 2016

PROGRAM FOR TRAPEZOIDAL RULE

/*PROGRAM FOR TRAPEZOIDAL RULE*/


#include<stdio.h>
#include<conio.h>
void main()
{
int n,i;
float x0,xf,y,h;
float f(float);
clrscr();
printf("\n\nEnter the values of x0 & xf::");
scanf("%f%f",&x0,&xf);
printf("\n\nEnter the values of n::");
scanf("%d",&n);
h=(xf-x0)/n;
y=f(x0)+f(xf);
for(i=1;i<=n-1;i++)
{
y=y+2*f(x0+i*h);
}
y=y*h/2;
printf("\n\nThe result is::%f",y);
getch();
}
float f(float x)
{
return(1/(1+x*x));
}


/* ******************OUTPUT*****************


Enter the values of x0 & xf::0
1
Enter the values of n::6
The result is::0.784241*/

ALGORITHM OF TRAPEZOIDAL RULE


ALGORITHM OF TRAPEZOIDAL RULE

1-Enter value of lower limit (a) & upper limit (b)
2-Enter the no. of sub-intervals (n)
3-h = (b-a) / n
4- s = y(a) + y(b)
5- for (j=1 to n-1)
  {
   s = s+2*y(a+i*h)
   }
6-Result = (h/2) * s
7- Print result
8- Exit ( )

ALGORITHM OF SIMPSON 3/8 RULE

ALGORITHM OF SIMPSON 3/8 RULE


1-Enter value of upper limit (a) and lower limit(b)
2-Enter value of sub-interval (n)
3-h = (b-a) / n
4-s = y(a) +y(b)
5-for (j = 1 to n-1)
   if (j % 3 = = 0)
   s = s+2*y(a+j*h)
   else
   s= s +3*y(a+j*h)
6- result = 3*(h/8) * s
7-Print result
8-exit ( )

ALGORITHM OF SIMPSON’S 1/3 RULE


ALGORITHM OF SIMPSON’S 1/3 RULE

1-Enter value of upper limit & lower limit
2-Enter value of sub-interval(n)
3-h=(b-a)/n
4-s=y(a)+y(b)
5-For (j=1 to n-1) dø
   if( j%2==0)
  {
   s= s+2*y(a+j*h)
  else
  s=s+4*y(a+j*h)
  }
6-Result = (h/3)*s
7-Print  “result”
8- exit( )

PROGRAM FOR SIMPSON 3/8 RULE

/*PROGRAM FOR SIMPSON 3/8 RULE*/


#include<stdio.h>
#include<conio.h>
void main()
{
int n,i;
float x0,xf,y,h;
float f(float);
clrscr();
printf("\n\nEnter the values of x0 & xf::");
scanf("%f%f",&x0,&xf);
printf("\n\nEnter the values of n::");
scanf("%d",&n);
if(n%3==0)
{
h=(xf-x0)/n;
y=f(x0)+f(xf);
for(i=1;i<=n-1;i++)
{
if(i%3==0)
y=y+2*f(x0+i*h);
else
y=y+3*f(x0+i*h);
}
y=(3*(y*h))/8;
printf("\n\nThe result is::%f",y);
}
else
goto X;
getch();
}
float f(float x)
{
return(1/(1+x*x));
}
/***************OUTPUT********************
Enter the values of x0 & xf::0
6
Enter the values of n::6

The result is::1.357081 */