Calculate Area and Circumference of a Circle in C

This program reads the radius of a circle and calculates its area and circumference using basic arithmetic operators. C Program #include <stdio.h> int main() { float radius, area, circumference; const float PI = 3.14159; printf(“Enter the radius of the circle: “); scanf(“%f”, &radius); area = PI * radius * radius; circumference = 2 * PI … Read more

Swap Two Numbers Without Using a Third Variable in C

This program shows how to swap the values of two variables without using a temporary (third) variable, using arithmetic operators. C Program #include <stdio.h> int main() { int a, b; printf(“Enter value of a: “); scanf(“%d”, &a); printf(“Enter value of b: “); scanf(“%d”, &b); printf(“\nBefore swapping: a = %d, b = %d\n”, a, b); a … Read more