C Programming - 24aiu1cp Sample Programs
C Programming - 24aiu1cp Sample Programs
Sample Programs
return 0;
}
6. C Program to calculate the area of a circle based on user input of the radius
#include <stdio.h>
int main() {
double pi = 3.14;
printf("Value of pi: %lf\n", pi); // Printing a double with %lf
double radius;
printf("Enter the radius of a circle: ");
scanf("%lf", &radius); // Reading a double with %lf
double area = pi * radius * radius; // Calculation using the entered radius
printf("Area of the circle with radius %.2lf is: %.2lf\n", radius, area);
return 0;
}
2|Page
7. C Program for arithmetic calculation
#include <stdio.h>
int main() {
int num1, num2; //Declaration of Variables
printf("Enter the first number: "); // Prompt the user to enter the first number
scanf("%d", &num1);
printf("Enter the second number: "); // Prompt the user to enter the second number
scanf("%d", &num2);