C Lab Manual
C Lab Manual
BASICS OF C PROGRAMMING
LAB EXPERIMENT
EXPERIMENT NO. – 1
1(A) AIM: - Write a C Program to compute an electricity bill based on the following slab rates.
#include <stdio.h>
int main() {
int oldReading, currentReading, units;
float billAmount = 0;
OUTPUT:-
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:1 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:2
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
1(B)
An insurance company computes the premium amount based on the following;
• If a person's health is excellent and the person is between 25 and 35 years of age and lives in a city, and is a male
then the premium is Rs.4 per thousand and the policy amount cannot exceed Rs.2 lakhs.
• If a person satisfies all the above conditions and is female then the premium is Rs.3 per thousand and the policy
amount cannot exceed Rs.1 lakh.
• If a person's health is poor and the person is between 25 and 35 years of age and lives in a village and is a male then
premium is Rs.6 per thousand and the policy cannot exceed Rs. 10000.
• In all other cases the person is not insured.
• Write a C program to determine whether the person should be insured or not, his/her premium rate and maximum
amount for which he/she can be insured.
CODE: -
#include <stdio.h>
if (health[0] == 'e' && age >= 25 && age <= 35 && residence[0] == 'c') {
if (gender[0] == 'm') {
premiumRate = 4.0;
policyAmount = 200000;
} else if (gender[0] == 'f') {
premiumRate = 3.0;
policyAmount = 100000;
}
} else if (health[0] == 'p' && age >= 25 && age <= 35 && residence[0] == 'v' && gender[0] == 'm') {
premiumRate = 6.0;
policyAmount = 10000;
}
if (premiumRate == 0) {
printf("The person is not insured.\n");
} else {
printf("The person is insured.\n");
printf("Premium rate: Rs.%.2f per thousand\n", premiumRate);
printf("Maximum insured amount: Rs.%d\n", policyAmount);
}
}
int main() {
char health[20], gender[10], residence[20];
int age;
OUTPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:1 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:4
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
1(C)
AIM: Write a C Program to find the grade for a student using a Switch case. The user needs to enter
subject score (varies from 0 to 100) and then display the grade as described below.
#include <stdio.h>
int main() {
int score;
char grade;
printf("Enter the subject score (0 to 100): ");
scanf("%d", &score);
OUTPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:5
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
EXPERIMENT NO. – 2
2(A) A Fibonacci sequence is defined as follows:
The first and second terms in the sequence are 0 and 1.
Sub-sequent terms are found by adding the preceding two terms in the sequence.
Write a C program to generate the first n terms of the sequence.
#include <stdio.h>
int main() {
int n, t1 = 0, t2 = 1, nextTerm;
scanf("%d", &n);
nextTerm = t1 + t2;
t1 = t2;
t2 = nextTerm;
return 0;
OUPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:6
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
2(B)
AIM: Write a C program to find the sum of individual digits of a positive integer
#include <stdio.h>
int main() {
int num, sum = 0, digit;
if (num < 0) {
printf("Please enter a positive integer.\n");
return 1;
}
return 0;
}
OUTPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:7
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
2(C)
AIM Write a C program to read two numbers x and n, and then compute the sum of the
geometric progression: 1+x+x2+x3+…………+xn. Show appropriate error message for n<0.
(Example: if n is 3 and x is 5, then the sum is: 1+5+25+125) .
#include <stdio.h>
int main() {
int x, n;
int term = 1;
int sum = 0;
if (n > 0) {
for (int i = 0; i <= n; i++) {
sum += term;
term *= x;
}
printf("The sum of the geometric progression is: %d\n", sum);
} else {
printf("Error: n must be a non-negative integer.\n");
}
return 0;
}
OUPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:8
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
2(d)
AIM: W r i t e a C p r o g r a m t o p r i n t t h e f o l l o w i n g p a t t e r n .
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
#include <stdio.h>
int main() {
int n = 5;
int i, j, k;
printf("\n");
}
return 0;
}
OUTPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:9
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
EXPERIMENT NO. – 3
3(A)
AIM: Write a C program to find both the largest and smallest numbers in a list of integers.
#include <stdio.h>
int main() {
int n, i, num;
int largest, smallest;
if (n <= 0) {
printf("Error: The list must have at least one element.\n");
return 1;
}
Output: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:10
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
3(B)
AIM: Write a C program that uses function to perform the following:
i) Addition of Two Matrices ii) Multiplication of Two Matrice
i) #include <stdio.h>
void addMatrices(int a[][MAX], int b[][MAX], int result[][MAX], int rows, int cols) {
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
result[i][j] = a[i][j] + b[i][j];
}
}
}
OUTPUT: -
ii)
#include <stdio.h>
void multiplyMatrices(int a[][MAX], int b[][MAX], int result[][MAX], int rows1, int cols1, int cols2) {
for (int i = 0; i < rows1; i++) {
for (int j = 0; j < cols2; j++) {
result[i][j] = 0;
for (int k = 0; k < cols1; k++) {
result[i][j] += a[i][k] * b[k][j];
}
}
}
}
int main() {
int rows1, cols1, rows2, cols2;
int a[MAX][MAX], b[MAX][MAX], result[MAX][MAX];
printf("Enter the number of rows and columns for the first matrix: ");
scanf("%d %d", &rows1, &cols1);
printf("Enter the number of rows and columns for the second matrix: ");
scanf("%d %d", &rows2, &cols2);
if (cols1 != rows2) {
printf("Matrix multiplication not possible.\n");
return 1;
}
return 0;
}
OUTPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:13
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
EXPERIMENT-4
4 (A)
AIM : Write a C program to insert a sub-string in to a main string at a given position..
#include <stdio.h>
#include <string.h>
int main() {
char mainStr[100], subStr[50], result[150];
int position, i = 0, j = 0;
j = position;
while (mainStr[j] != '\0') {
result[i] = mainStr[j];
i++;
j++;
}
result[i] = '\0';
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:14
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
result[i] = '\0';
return 0;
}
OUTPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:15
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
4(B)
AIM: Write a C program to count the lines, words and characters in a given text.
#include <stdio.h>
#include <ctype.h>
int main() {
char ch;
int lines = 0, words = 0, characters = 0;
int inWord = 0;
if (ch == '\n') {
lines++;
}
if (isspace(ch)) {
inWord = 0;
} else if (!inWord) {
inWord = 1;
words++;
}
}
if (characters > 0) {
lines++;
}
OUTPUT: -
-
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:16
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
EXPERIMENT-5
5(A)
AIM: Write a C program to generate all the prime numbers between 1 and n, where n is a value entered by the
user. Define a separate function to generate prime numbers.
#include <stdio.h>
int isPrime(int num) {
if (num <= 1) return 0;
for (int i = 2; i < num; i++) {
if (num % i == 0) return 0;
}
return 1;
}
int main() {
int n;
return 0;
}
OUTPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:17
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
5(B)
AIM: Write C program that uses recursive function to find the following.
i) Factorial of a given integer ii) GCD of two given integers
#include <stdio.h>
int factorial(int n) {
if (n == 0 || n == 1) {
return 1;
} else {
return n * factorial(n - 1);
}
}
int main() {
int choice, num, num1, num2;
while (1) {
printf("\nMenu:\n");
printf("1. Calculate Factorial\n");
printf("2. Calculate GCD\n");
printf("3. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("Enter a positive integer: ");
scanf("%d", &num);
if (num < 0) {
printf("Factorial of a negative number doesn't exist.\n");
} else {
printf("Factorial of %d = %d\n", num, factorial(num));
}
break;
case 2:
printf("Enter two integers: ");
scanf("%d %d", &num1, &num2);
printf("GCD of %d and %d = %d\n", num1, num2, gcd(num1, num2));
break;
case 3:
printf("Exiting the application.\n");
return 0;
default:
printf("Invalid choice. Please try again.\n");
}
}
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:18
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
case 3:
printf("Exiting the application.\n");
return 0;
default:
printf("Invalid choice. Please try again.\n");
}
}
return 0;
}
Output: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:19
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
EXPERIMENT-6
6(A)
AIM: Write a C program to print the elements of an array in reverse order using pointers.
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3, 4, 5};
int size = sizeof(arr) / sizeof(arr[0]);
return 0;
}
OUTPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:20
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
6(B)
AIM: Write a C program to count the number of vowels and consonants in a string using pointers
#include <stdio.h>
#include <ctype.h>
int main() {
char str[100];
char *ptr;
int vowels = 0, consonants = 0;
ptr = str;
return 0;
}
OUTPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:21
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
6(C)
AIM: Write a C program to store n elements in an array and print the elements in sorted order usingpointers.
#include <stdio.h>
void sortArray(int *arr, int n) {
int temp;
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
if (*(arr + i) > *(arr + j)) {
temp = *(arr + i);
*(arr + i) = *(arr + j);
*(arr + j) = temp;
}
}
}
}
int main() {
int n;
printf("Enter the number of elements in the array: ");
scanf("%d", &n);
int arr[n];
printf("Enter the elements of the array:\n");
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
sortArray(arr, n);
printf("The elements in sorted order are:\n");
for (int i = 0; i < n; i++) {
printf("%d ", *(arr + i));
}
printf("\n");
return 0;
}
OUTPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:22
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
EXPERIMENT-7
7(A)
AIM: ) Write a C program that performs the following operations:
Reading a complex number ii. Writing a complex number
iii. Addition of two complex number iv. Multiplication of two complex numbers
#include <stdio.h>
typedef struct {
float real;
float imag;
} Complex;
Complex readComplex() {
Complex c;
printf("Enter the real part: ");
scanf("%f", &c.real);
printf("Enter the imaginary part: ");
scanf("%f", &c.imag);
return c;
}
void writeComplex(Complex c) {
printf("%.2f + %.2fi\n", c.real, c.imag);
}
int main() {
Complex c1, c2, sum, product;
return 0;
}
Explanation:
OUTPUT: 1.- Structure Definition:
o typedef struct { float real; float imag; } Complex; defines a structure to represent
complex numbers with real and imaginary parts.
2. Function to Read a Complex Number:
o Complex readComplex(): Reads the real and imaginary parts of a complex number
from the user and returns the complex number.
3. Function to Write (Display) a Complex Number:
o void writeComplex(Complex c): Prints the complex number in the format "a + bi".
4. Function to Add Two Complex Numbers:
o Complex addComplex(Complex c1, Complex c2): Adds the real parts and the
imaginary parts of two complex numbers and returns the resulting complex number.
5. Function to Multiply Two Complex Numbers:
o Complex multiplyComplex(Complex c1, Complex c2): Multiplies two complex
numbers using the formula (a + bi)(c + di) = (ac - bd) + (ad + bc)i and returns the
resulting complex number.
6. Main Function:
o Reads two complex numbers from the user.
o Writes the complex numbers to the console.
o Calculates and displays the sum of the two complex numbers.
o Calculates and displays the product of the two complex numbers.
Feel free to test this program with different complex numbers. Let me know if you have any questions
or need further assistance!
Message Copilot
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:24
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
7(B)
AIM: D e f i n e a s t r u c t u r e t o s t o r e e m p l o y e e d e t a i l s i n c l u d e E m p l o y e e - N u m b e r , E m p l o y e e -
Name, Basic-pay, Date-of-Joining. Write a C program for the foll owing.
i.A fun ction to st ore 10 employee details.
ii. A function to implement the follow ing rules while revising the basic pay.
If Basic-pay<=Rs.5000 then increase it by 15%.
If Basic-pay> Rs .5000 and <=Rs .25000 the n it increase by10%.
If Basic-pay>Rs.25000 then there is no cha nge in Basic -pay.
iii. A funct ion t o print the detail s of employees who have completed 20 years of service from
the Date-of-Joining
#include <stdio.h>
#include <string.h>
typedef struct {
int empNumber;
char empName[50];
float basicPay;
int joinDay;
int joinMonth;
int joinYear;
} Employee;
int main() {
int size = 10;
Employee employees[size];
EmployeeDetails(employees, size);
reviseBasicPay(employees, size);
int currentYear;
printf("Enter the current year: ");
scanf("%d", ¤tYear);
return 0
}
Output: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:26
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
EXPERIMENT-8
8(A)
AIM: Write a C program to reverse the first n characters of a given text file.
#include <stdio.h>
#include <stdlib.h>
int main() {
FILE *file;
char *filename = "input.txt";
int n;
reverseCharacters(buffer, n);
]
fseek(file, 0, SEEK_SET);
free(buffer);
fclose(file);
printf("First %d characters have been reversed and written back to the file.\n", n);
return 0;
}
OUTPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:28
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
8(b)
#include <stdio.h>
#include <stdlib.h>
void mergeFiles(const char *file1, const char *file2, const char *outputFile) {
FILE *f1 = fopen(file1, "r");
FILE *f2 = fopen(file2, "r");
FILE *out = fopen(outputFile, "w");
char ch;
fclose(f1);
fclose(f2);
fclose(out);
}
int main() {
const char *file1 = "file1.txt";
const char *file2 = "file2.txt";
const char *outputFile = "merged.txt";
return 0;
}
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:29
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
OUTPUT: -
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:30
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
EXPERIMENT-9
AIM: Develop a phone book application to save users contact information include name, mobile number and email
id as well as to edit and delete contact details.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
Contact phoneBook[MAX];
int contactCount = 0;
void addContact() {
if (contactCount < MAX) {
printf("Enter Name: ");
scanf(" %[^\n]", phoneBook[contactCount].name);
printf("Enter Mobile Number: ");
scanf("%s", phoneBook[contactCount].mobile);
printf("Enter Email ID: ");
scanf("%s", phoneBook[contactCount].email);
contactCount++;
printf("Contact added successfully.\n");
} else {
printf("Phone book is full.\n");
}
}
void displayContacts() {
if (contactCount == 0) {
printf("No contacts to display.\n");
return;
}
for (int i = 0; i < contactCount; i++) {
printf("Contact %d:\n", i + 1);
printf("Name: %s\n", phoneBook[i].name);
printf("Mobile: %s\n", phoneBook[i].mobile);
printf("Email: %s\n", phoneBook[i].email);
printf("\n");
}
}
void editContact() {
char name[50];
printf("Enter the name of the contact to edit: ");
scanf(" %[^\n]", name);
for (int i = 0; i < contactCount; i++) {
if (strcmp(phoneBook[i].name, name) == 0) {
printf("Enter new Mobile Number: ");
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:31
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
void saveContacts() {
FILE *file = fopen("phonebook.txt", "w");
if (file == NULL) {
printf("Error opening file.\n");
return;
}
for (int i = 0; i < contactCount; i++) {
fprintf(file, "%s %s %s\n", phoneBook[i].name, phoneBook[i].mobile, phoneBook[i].email);
}
fclose(file);
printf("Contacts saved to file successfully.\n");
}
void loadContacts() {
FILE *file = fopen("phonebook.txt", "r");
if (file == NULL) {
printf("Error opening file.\n");
return;
}
contactCount = 0;
while (fscanf(file, " %49[^\n] %14s %49s", phoneBook[contactCount].name, phoneBook[contactCount].mobile,
phoneBook[contactCount].email) != EOF) {
contactCount++;
}
fclose(file);
printf("Contacts loaded from file successfully.\n");
}
int main() {
int choice;
loadContacts();
do {
printf("\nPhone Book Menu:\n");
printf("1. Add Contact\n");
printf("2. Display Contacts\n");
printf("3. Edit Contact\n");
printf("4. Delete Contact\n");
printf("5. Save Contacts\n");
printf("6. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
GEETA UNIVERSITY, PANIPAT
LABORATORY MANUAL
EXPERIMENT NO.:4 ISSUE NO: ISSUE DATE :
Course Outcome: REV. DATE PAGE:32
SCHOOL OF COMPUTER LABORATORY: BASIC OF C PROGRAMING
SCIENCE & ENGINEERING SEMESTER: 1
scanf("%d", &choice);
switch (choice) {
case 1:
addContact();
break;
case 2:
displayContacts();
break;
case 3:
editContact();
break;
case 4:
deleteContact();
break;
case 5:
saveContacts();
break;
case 6:
printf("Exiting the application.\n");
break;
default:
printf("Invalid choice. Please try again.\n");
}
} while (choice != 6);
return 0;
}
OUTPUT: -