---------------------------------------------------------------------- AGRA

B.C.A FIRST SEMESTER

>>>> LAB ASSINGMENT>>>> --------------------------------------------------------------------------- 1- Write a program to compute area and circumference of a circle. Program-

#include<stdio.h>

#include<conio.h>

Void main()

{

float radius,circumference,area;

clrscr();

printf(“the radius of circle= ”);

scanf(“%f”,radius);

circumference=2*3.14*radius;

area=3.14*radius*radius;

printf(“the area of circle=%f \n the circumference=%f”,area,circumference); getch();

}

2- Write a program converts a temperature from Celsius to Fahrenheit. Use the following formula: F = 1.8 x C + 32 . Program-

#include<stdio.h>

#include<conio.h>

void main()

float celsius, farenheit;

clrscr();

printf(“temperature in celsius= ”);

scanf(“%f”,celsius);

farenheit=1.8*c+32;

printf(“\nthe temp in farenheit=%f”,farenheit);

getch();

}

3- Write a complete C Program that prompts the user for the Cartesian Coordinates of two points (x1, y1) and (x2, y2 ) and displays the distance between them computed using the following formula : Distance =

Program-

#include<stdio.h>

#include<math.h>

#include<conio.h>

Void main()

{

float x1,x2,y1,y2,distance;

clrscr();

printf(“the co-ordinates are=”);

scanf(“%f %f %f %f”, &x1,&x2,&y1,&y2);

distance=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));

printf(“distance=%f”,distance);

getch();

}

4.Write a program that reads the lengths of two sides of a triangle and the angle between them and calculates the length of the third side using the following formula:

Program-

#include<stdio.h>

#include<math.h>

#include<conio.h>

Void main()

{

float side1,side2 ,side3,angle;

clrscr();

printf(“enter the two sides of triangle and angle between them=”); scanf(“%f %f %f “,&side1,&side2 &angle);

side3=sqrt((side1*side1+side2*side2-2*side1*side2*Cos(angle))); printf(“the third side is=%f”,side3);

getch()

}

5.Write a program that reads the volume of a sphere and finds the radius of it.

8.Write a program to generate Square, Cube, and Square Root of positive numbers from 1 to any Limit Entered by user. (Note: Solve using for loop).

Program-

#include<stdio.h>

#include<math.h>

#include<conio.h>

void main()

{

long int i=1,n,square,cube,square_root;

clrscr();

printf("enter the value=");

scanf("%ld",&n);

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

{

square=n*n;

printf("square=%ld",square);

cube=n*n*n;

printf("\ncube=%ld",cube);

square_root=sqrt(n);

printf("\nsquare_root=%ld",square_root);

getch();

}

}

9.Write a program to find the roots of a quadratic equation. Consider the case of imaginary roots. Program-

#include<stdio.h>

#include<math.h>

#include<conio.h>

void main()

{

float a,b,c,discriminent,root1,root2;

clrscr();

printf(“enter the values of a ,b,andc=”);

scanf(“%f %f %f”,&a,&b,&c);

discriminent=b*b-4*a*c;

if (discriminent<0)

printf(“roots are imageinary”);

else

{

root1=(-b+sqrt(discriminent))/(2.0*a);

root2=(-b-sqrt(discriminent))/(2.0*a);

printf(“\n\nroot1 =%5.2f\n\nroot2=%5.2f”,root1,root2”); getch();

}

}

10.Write a program that reads three integer numbers and prints the highest among them. #include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c;

clrscr();

printf(“enter the value of a,b, and c=”);

scanf(“%d%d%d”,&a,&b,&c);

if(a>b&&a>c)

printf(“a is greatest”);

else if(b>c)

printf(“b is greatest”);

else

printf(“c is greatest);

}

11.Write a program that prompts the user for the day number (0 to 6) and prints the day name (Saturday to Friday)...