Clab Solution
Clab Solution
Clab Solution
Lab1 Write the program to add two numbers entered from a #include<stdio.h> keyboard. #include<conio.h> void main() {int a,b,sum=0; printf("Enter the two number:"); scanf("%d%d",&a,&b); sum=a+b; printf("Sum is:%d",sum); getch(); } Write a program to print sum, product and quotient of two numbers 22 and #include<stdio.h> 7. #include<conio.h> void main() {int a=22,b=7,sum,prodt; float quet; sum=a+b; prodt=a*b; quet=(float)a/b; printf("sum is:%d",sum); printf("Product is:%d",prodt); printf("Question is:%f",quet); getch(); } Write a C Program to calculate the volume of a pool. The equation for the volume determining is Vol ume = length x width x depth. Assume that the pool has a length of 25 feet, a width of feet and depth 6 feet. 10 #include<stdio.h> #include<conio.h> void main() {int l=25,b=10,d=6,volume; volume=l*b*d; printf("Volume of pool %d",volume); getch(); } Write a program to input temperature in Celsius & to print its Fahrenheit #include<stdio.h> equivalent. #include<conio.h> void main() { float c,f; printf("Enter the temperature in centigrade"); scanf("%f",&c); f=(5.0/9.0)*(c+32.0); printf("Temperature in farenheit is:%f",f); getch(); } Write a program to find the number of digits of an integer (Hints find logarithm and add one on the integer part.) #include<stdio.h> #include<conio.h> #include<math.h> void main() {
Page 1
Page 2
Page 3
Page 4
Page 5
Page 6
Page 7
Page 8
Page 9
Page 10
Page 11
Page 12
Page 13
Page 14
Page 15
Page 16
Page 17
Page 18
Page 19
Page 20
x 1!
x2 2!
x3 3!
.......... ........
( 1) n
xn n!
#include<stdio.h> #include<conio.h> #include<math.h> float series(int n,float x); main() { int n; float x,y; printf("enter the value of n:"); scanf("%d",&n); printf("enter the value of x:"); scanf("%f",&x); y=series(n,x); printf("y=%f",y); getch(); return(0); } float series(int n,float x) { float term=(-x),sum=1; int i; for(i=1;i<n;i++) {sum+=term; term*=(-x)/(i+1); } return(sum); } Write a program to calculate the value of combination of n different objects taken r at a time. C(n,r) =
n! (n r )!r!
#include<stdio.h> #include<conio.h> long int fact(int n); main() {int r,n,s; long int comb; printf("Enter the value of n:"); scanf("%d",&n);
Page
Page 22
Page 23
Page 24
Page 25
Page 26
Page 27
Page 28
Page 29
Page 30
Page 32
Page 33
Page 34
Page 35
Page 36
Page 37