/* ***************************************************
11. To Find the Volume of Cylinder
************************************************** */
#include<*stdio.h>
#include<*conio.h>
#define pi 3.14
void main()
{
float r,h,v;
clrscr();
printf("\n Enter the Values of :\n");
printf("\n Radius of Cylinder = ");
scanf("%f", &r);
printf("\n Length/Height of Cylinder = ");
scanf("%f", &h);
v = pi*r*r*h;
printf("\n\n Volume of Given Cylinder is : %f ", v);
getch();
}
Output :
Enter the Values of :
Radius of Cylinder = 1
Length/Height of Cylinder = 2
Volume of Given Cylinder is : 6.28
11. To Find the Volume of Cylinder
************************************************** */
#include<*stdio.h>
#include<*conio.h>
#define pi 3.14
void main()
{
float r,h,v;
clrscr();
printf("\n Enter the Values of :\n");
printf("\n Radius of Cylinder = ");
scanf("%f", &r);
printf("\n Length/Height of Cylinder = ");
scanf("%f", &h);
v = pi*r*r*h;
printf("\n\n Volume of Given Cylinder is : %f ", v);
getch();
}
Output :
Enter the Values of :
Radius of Cylinder = 1
Length/Height of Cylinder = 2
Volume of Given Cylinder is : 6.28
/* *************************************************
12. To Impliment Various Arithmetic Operations all at a time
************************************************** */
#include<*stdio.h>
#include<*conio.h>
void main()
{
float a,b,sum,diff,mul,div;
clrscr();
printf("\n Enter any Two Values to do all Arithmetic Operations : ");
scanf("%f %f", &a, &b);
sum = a+b;
printf("\n %f + %f = %f \n", a, b, sum);
diff = a-b;
printf("\n %f - %f = %f \n", a, b, diff);
mul = a*b;
printf("\n %f * %f = %f \n", a, b, mul);
div = a/b;
printf("\n %f / %f = %f \n", a, b, div);
getch();
}
Output :
Enter any Two Values to do all Arithmetic Operations : 2 4
2 + 4 = 6
2 - 4 = -2
2 * 4 = 8
2 / 4 = 0.5
12. To Impliment Various Arithmetic Operations all at a time
************************************************** */
#include<*stdio.h>
#include<*conio.h>
void main()
{
float a,b,sum,diff,mul,div;
clrscr();
printf("\n Enter any Two Values to do all Arithmetic Operations : ");
scanf("%f %f", &a, &b);
sum = a+b;
printf("\n %f + %f = %f \n", a, b, sum);
diff = a-b;
printf("\n %f - %f = %f \n", a, b, diff);
mul = a*b;
printf("\n %f * %f = %f \n", a, b, mul);
div = a/b;
printf("\n %f / %f = %f \n", a, b, div);
getch();
}
Output :
Enter any Two Values to do all Arithmetic Operations : 2 4
2 + 4 = 6
2 - 4 = -2
2 * 4 = 8
2 / 4 = 0.5
/* **************************************************
13. To Find the Sum of first 'n' Natural Numbers
************************************************* */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int n,sn1;
clrscr();
printf("\n Enter n,To Find Sum of First n Natural Numbers : ");
scanf("%d", &n);
sn1 = n*(n+1)/2;
printf("\n\n Sum of First %d Natural Numbers is : %d", n, sn1);
getch();
}
Output :
Enter The Values of n,To Find Sum of First n Natural Numbers : 5
Sum of First 5 Natural Numbers is : 15
13. To Find the Sum of first 'n' Natural Numbers
************************************************* */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int n,sn1;
clrscr();
printf("\n Enter n,To Find Sum of First n Natural Numbers : ");
scanf("%d", &n);
sn1 = n*(n+1)/2;
printf("\n\n Sum of First %d Natural Numbers is : %d", n, sn1);
getch();
}
Output :
Enter The Values of n,To Find Sum of First n Natural Numbers : 5
Sum of First 5 Natural Numbers is : 15
/* ***************************************************
14. To Find the Sum of Squares of First 'n' Natural Numbers
************************************************ */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int n,sn2;
clrscr();
printf("\n Enter n,To Find Sum of Squares of First n Natural Numbers : ");
scanf("%d", &n);
sn2 = n*(n+1)*(2*n+1)/6;
printf("\n\n Sum of Squares of First %d Natural Numbers is : %d", n, sn2);
getch();
}
Output :
Enter The Value of n,To Find Sum of Squares of First n Natural Numbers : 5
Sum of Squares of First 5 Natural Numbers is : 55
14. To Find the Sum of Squares of First 'n' Natural Numbers
************************************************ */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int n,sn2;
clrscr();
printf("\n Enter n,To Find Sum of Squares of First n Natural Numbers : ");
scanf("%d", &n);
sn2 = n*(n+1)*(2*n+1)/6;
printf("\n\n Sum of Squares of First %d Natural Numbers is : %d", n, sn2);
getch();
}
Output :
Enter The Value of n,To Find Sum of Squares of First n Natural Numbers : 5
Sum of Squares of First 5 Natural Numbers is : 55
/* **************************************************
15. To Find the Sum of Cubes of First 'n' Natural Numbers
************************************************ */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int n,sn3;
clrscr();
printf("\n Enter n,To Find Sum of Cubes of First n Natural Numbers : ");
scanf("%d", &n);
sn3 = n*(n+1)*(n+1)*n/4;
printf("\n\n Sum of Cubes of First %d Natural Numbers is : %d", n, sn3);
getch();
}
Output :
Enter The Values of n,To Find Sum of Cubes of First n Natural Numbers : 5
Sum of Cubes of First 5 Natral Numbers is : 225
15. To Find the Sum of Cubes of First 'n' Natural Numbers
************************************************ */
#include<*stdio.h>
#include<*conio.h>
void main()
{
int n,sn3;
clrscr();
printf("\n Enter n,To Find Sum of Cubes of First n Natural Numbers : ");
scanf("%d", &n);
sn3 = n*(n+1)*(n+1)*n/4;
printf("\n\n Sum of Cubes of First %d Natural Numbers is : %d", n, sn3);
getch();
}
Output :
Enter The Values of n,To Find Sum of Cubes of First n Natural Numbers : 5
Sum of Cubes of First 5 Natral Numbers is : 225
0 comments:
Post a Comment