Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

5a) AREA AND CIRCUMFERENCE OF A CIRCLE

PROGRAM:
#include<stdio.h>
int main()
{
int rad;
float PI=3.14,area,ci;
printf("Enter radius of circle: ");
scanf("%d",&rad);
area = PI * rad * rad;
printf("Area of circle : %f ",area);
ci = 2 * PI * rad;
printf("Circumference : %f ",ci);
return(0);
}
OUTPUT:
Enter radius of a circle : 1
Area of circle : 3.14
Circumference : 6.28

5b) TEMPERATURE CONVERSION

PROGRAM:
#include<stdio.h>
void main ()
{
float temp_c, temp_f;
clrscr();
printf ("Enter the value of Temperature in Celsius: ");
scanf ("%f", &temp_c);
temp_f = (1.8 * temp_c) + 32;
printf ("The value of Temperature in Fahrenheit is: %f",
temp_f);
getch();
}
OUTPUT:
Enter the value of Temperature in Celsius: 30
The value of Temperature in Fahrenheit is: 86.000000

5c) THE GIVEN NO IS POSITIVE OR NEGATIVE

PROGRAM
#include<stdio.h>
main()
{
int a;
printf(Enter the number);
scanf(%d,&a);
if(a>0)
printf(a is positive);
else if (a<0)
printf(a is negative);
else
printf(a is equal to zero);
}
OUTPUT:
Enter the number 93
a is positive

5 d) QUADRATIC EQUATION
PROGRAM:
#include<stdio.h>
#include<math.h>
int main(){
float a,b,c;
float d,root1,root2;
clrscr();
printf("Enter a, b and c of quadratic equation: ");
scanf("%f%f%f",&a,&b,&c);
d = b * b - 4 * a * c;
if(d < 0){
printf("Roots are complex number.\n");
printf("Roots of quadratic equation are: ");
printf("%.3f%+.3fi",-b/(2*a),sqrt(-d)/(2*a));
printf(", %.3f%+.3fi",-b/(2*a),-sqrt(-d)/(2*a));
return 0;
}
else if(d==0){
printf("Both roots are equal.\n");
root1 = -b /(2* a);
printf("Root of quadratic equation is: %.3f ",root1);
return 0;
}
else{
printf("Roots are real numbers.\n");
root1 = ( -b + sqrt(d)) / (2* a);
root2 = ( -b - sqrt(d)) / (2* a);
printf("Roots of quadratic equation are: %.3f , %.3f",root1,root2);

}
getch();
return 0;
}

OUTPUT:
Enter a, b and c of quadratic equation: 2 4 1
Roots are real numbers.
Roots of quadratic equation are: -0.293, -1.707

5e) GENERATE NUMBERS DIVISIBLE BY 2 NOT BY 3 AND 5


PROGRAM:

#include<stdio.h>
#include<conio.h>
main()
{
int i;
clrscr();
printf("The numbers divisble by 2 not by 3 & 5 are : \n");
for( i=1;i<=100;i++)
{
if((i%2==0) && (i%3!=0) && (i%5!=0))
printf("%5d", i);
}
getch();
}
OUTPUT:
The numbers divisble by 2 not by 3 & 5 are :

8 14

16 22 26 28 32 34 38 44 46 52 56 58 62 64 68
74 76 82 86 88 92 94 98

5f) SUM OF DIGITS OF A NUMBER


PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,d,sum=0;
clrscr();
printf("Enter the number:\n");
scanf("%d",&n);
while(n>0)
{
d=n%10;
sum=sum+d;
n=n/10;
}
printf("\nThe sum of the digits is %d",sum);
getch();
}
OUTPUT:
Enter the number:
2611
The sum of the digits is 10

You might also like