19.1 Class Activity RESULT
19.1 Class Activity RESULT
Topic Functions in C
1. Calculate Area of a Circle: Write a C program to calculate the area of a circle using
a function that takes the radius as an argument and returns the area.
CODE:
#include <stdio.h>
#define PI 3.14159
int main() {
double radius, area;
printf("Keshav\n");
printf("590015575\n");
area = calculateArea(radius);
printf("The area of the circle with radius %.2f is: %.2f\n", radius, area);
return 0;
}
OUTPUT:
2. Display Student Information: Create a C program that uses a function to display a
student's details, including name, roll number, and marks.
CODE:
#include <stdio.h>
struct Student {
char name[50];
long roll_number;
float marks;
};
int main() {
struct Student student1 = {"KESHAV", 24, 100};
display_student_info(student1);
return 0;
}
OUTPUT;
3. Employee Data Entry and Display: Write a C program to allow entry and display of
an employee's details such as name, ID, department, and salary, using functions to
handle the data.
CODE;
#include <stdio.h>
#include <string.h>
printf("\nEmployee Details:\n");
printf("ID: %d\n", emp.id);
printf("Name: %s\n", emp.name);
printf("Department: %s\n", emp.department);
printf("Salary: %.2f\n", emp.salary);
}
int main() {
printf("Keshav\n");
printf("590015575\n");
struct Employee emp;
inputEmployeeDetails(&emp);
displayEmployeeDetails(emp);
return 0;
}
OUTPUT;
int main() {
float basic_salary, hra, da, total_salary;
printf("Keshav\n");
printf("590015575\n");
printf("Enter the basic salary: ");
scanf("%f", &basic_salary);
return 0;
}
OUTPUT:
5. Simple Banking System for Deposit and Withdrawal: Implement a simple banking
system in C with options to deposit, withdraw, and check balance using functions,
displaying a menu for user actions.
CODE:
#include <stdio.h>
int main() {
float balance = 0.0;
int choice;
do {
switch(choice) {
case 1:
deposit(&balance);
break;
case 2:
withdraw(&balance);
break;
case 3:
check_balance(balance);
break;
case 4:
printf("Exiting the system. Goodbye!\n");
break;
default:
printf("Invalid choice. Please try again.\n");
}
} while(choice != 4);
return 0;
}
OUTPUT: