answersLogoWhite

0

AllQ&AStudy Guides
Best answer

#include<stdio.h>

int main(){

int line,i,j,k;

printf("Enter the no. of lines");

scanf("%d",&line);

for(i=1;i<=line;i++){

for(j=1;j<=line-i;j++)

printf(" ");

for(k=1;k<i;k++)

printf("%d",k);

for(k=i;k>=1;k--)

printf("%d",k);

printf("\n");

}

return 0;

}

This answer is:
Related answers

#include<stdio.h>

int main(){

int line,i,j,k;

printf("Enter the no. of lines");

scanf("%d",&line);

for(i=1;i<=line;i++){

for(j=1;j<=line-i;j++)

printf(" ");

for(k=1;k<i;k++)

printf("%d",k);

for(k=i;k>=1;k--)

printf("%d",k);

printf("\n");

}

return 0;

}

View page

n(n+1)/2

You can see this from the following:

Let x=1+2+3+...+n

This is the same as x=n+(n-1)+...+1

x=1+2+3+...+n

x=n+(n-1)+...+1

If you add the corresponding terms on the right-hand side of the two equations together, they each equal n+1 (e.g., 1+n=n+1, 2+n-1=n+1, ..., n+1=n+1). There are n such terms. So adding the each of the left-hand sides and right-hand sides of the two equations, we get:

x+x=(n+1)+(n+1)+...+(n+1) [with n (n+1) terms on the right-hand side

2x=n*(n+1)

x=n*(n+1)/2

A more formal proof by induction is also possible:

(1) The formula works for n=1 because 1=1*2/2.

(2) Assume that it works for an integer k.

(3) Now show that given the assumption that it works for k, it must also work for k+1.

By assmuption, 1+2+3+...+k=k(k+1)/2. Adding k+1 to each side, we get:

1+2+3+...+k+(k=1)=k(k+1)/2+(k+1)=k(k+1)/2+2(k+1)/2=(k(k+1)+2(k+1))/2=((k+2)(k+1))/2=(((k+1)+1)(k+1))/2=((k+1)((k+1)+1)/2

View page

0.3 M

View page

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<conio.h>

void main(void)

{

int K, P, C, J;

double A[100][101];

int N;

int Row[100];

double X[100];

double SUM, M;

int T;

do

{

printf("Please enter number of equations [Not more than %d]\n",100);

scanf("%d", &N);

} while( N > 100);

printf("You say there are %d equations.\n", N);

printf("From AX = B enter elements of [A,B] row by row:\n");

for (K = 1; K <= N; K++)

{

for (J = 1; J <= N+1; J++)

{

printf(" For row %d enter element %d please :\n", K, J);

scanf("%lf", &A[K-1][J-1]);

}

}

for (J = 1; J<= N; J++) Row[J-1] = J - 1;

for (P = 1; P <= N - 1; P++)

{

for (K = P + 1; K <= N; K++)

{

if ( fabs(A[Row[K-1]][P-1]) > fabs(A[Row[P-1]][P-1]) )

{

T = Row[P-1];

Row[P-1] = Row[K-1];

Row[K-1] = T;

}

}

if (A[Row[P-1]][P-1] 0)

{

printf("The matrix is SINGULAR !\n");

printf("Cannot use algorithm --- exit\n");

exit(1);

}

X[N-1] = A[Row[N-1]][N] / A[Row[N-1]][N-1];

for (K = N - 1; K >= 1; K--)

{

SUM = 0;

for (C = K + 1; C <= N; C++)

{

SUM += A[Row[K-1]][C-1] * X[C-1];

}

X[K-1] = ( A[Row[K-1]][N] - SUM) / A[Row[K-1]][K-1];

}

for( K = 1; K <= N; K++)

printf("X[%d] = %lf\n", K, X[K-1]);

getch();

}

View page

n=1 a(1) = 0.001

n=2 a(2) = 0.012

n=3 a(3) = 0.144

n=4 a(4) = 1.728

n=5 a(5) = 20.736

....

n=k a(k) = (12^(k-1))/1000

let n = k+1

a(k+1) = 12^(k)/1000

12(ak) = a(k+1)

12(12^k-1)/1000 = 12^k/1000

the 12 gets absorbed here.

12^(k-1+1)/1000 = 12^k/1000

Valid for k and k+1

therefore our equation

A(n) = 12^(n-1)/1000, n(greater than or equal to) 1

View page
Featured study guide
📓
See all Study Guides
✍️
Create a Study Guide
Search results