Monday, July 18, 2011

Write a c program to find out the sum of series 1^2 + 2^2 + �. + n^2.




Sum
of 1^2 + 2^2 + �. + n^2 series in c programming language




#include



int main(){



int n,i;

int sum=0;



printf("Enter
the n i.e. max values of series: ");

scanf("%d",&n);



sum
= (n * (n + 1) * (2 * n + 1 )) / 6;



printf("Sum of
the series : ");



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

if (i != n)

printf("%d^2 +
",i);

else

Write a c program to find out the sum of series 1 + 2 + �. + n.




Sum
of 1 + 2 + �. + n series in c programming language




#include

int main(){



int n,i;

int sum=0;



printf("Enter
the n i.e. max values of series: ");

scanf("%d",&n);



sum
= (n * (n + 1)) / 2;



printf("Sum of
the series: ");



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

if (i!=n)

printf("%d +
",i);

else

printf("%d =

Sunday, July 17, 2011

SUBTRACTION OF TWO MATRICES USING C PROGRAM


#include

int main(){

int a[3][3],b[3][3],c[3][3],i,j;


printf("Enter the First
matrix->");

for(i=0;i<3;i++)

for(j=0;j<3;j++)


scanf("%d",&a[i][j]);


printf("\nEnter the Second
matrix->");

for(i=0;i<3;i++)

for(j=0;j<3;j++)


scanf("%d",&b[i][j]);


printf("\nThe First matrix is\n");

for(i=0;i<3;i++){


printf("\n");

for(j=0

Write a c program to find the perimeter of a circle, rectangle and triangle


Formula of
perimeter of different shapes in geometry:



1. Square = 4 * a

2. Rectangle: 2 * (a + b)

3. General triangle: a + b + c

4. Equilateral triangle: 3 * a

5. Right angled triangle: w + l + v (w2 + l2)

6. Circle: 2 * p * r

7. Parallelogram: 2 * (a + b)

8. Rhombus: 4 * a

9. Cube: 12 * a

10. Cuboids: 4 * (w + l + h)

11. Trapezium: a + b + c + d

12. Equilateral polygon: n * a

13.

Saturday, July 16, 2011

Write a c program to find the volume and surface area of sphere

C program for area of a sphere







Formula of surface area of sphere:

Surface_area = 4 * Pie * r2



Formula of volume of sphere:

Volume = 4/3 * Pie * r3

Pie = 22/7 or 3.14159265358979323846264338327950288419716939937510...



C code:



#include

#include



int main(){



float r;

float surface_area,volume;



printf("Enter radius of the sphere : ");

Write a c program to find the volume and surface area of cone






Formula of surface
area of cone:

Surface_area = Pie * r * (r + v (r2 + h2))



Formula of volume
of cone:

Volume = 1/3 * Pie * r2 * h

Pie = 22/7 or
3.14159265358979323846264338327950288419716939937510...




Write a c program or code to find or calculate the volume and surface area of cone




#include

#include



int main(){



float r,h;

float
surface_area,

Write a c program to find the volume and surface area of cylinder




C
program for area of a cylinder






Formula of surface
area of cylinder:

Surface_area = 2 * Pie * r * (r + h)



Formula of volume
of cylinder:

Volume = Pie * r * r * h

Pie = 22/7 or
3.14159265358979323846264338327950288419716939937510...



C code:



#include

#include



int main(){



float r,h;

float
surface_area,volume;



printf("Enter
size of