FPL Prac Mannual
FPL Prac Mannual
5
Practical -5 Write a C program for employee salary calculation given,
Basic, H.R.A. 20 % of Basic and D.A. 150 % of Basic.
6
Practical -6 To accept a student's marks for five subjects, compute
his/her result.
RDTC/SCSCOE/FE/CHEMpg.1
Rajgad Dnyanpeeth’s
RAJGAD DNYANPEETH TECHNICAL CAMPUS
S.No.237,Satara-Pune,NH-4,Dhangawadi,Tal:Bhor,Dist:Pune(Maharashtra)
Date of Performance:
Signature of staff with date
OUTCOMES:
THEORY:
This assignment will read the number and perform different operations
on that number.
Variable:
In programming, a variable is a container (storage area) to hold data. To indicate the
storage area, each variable should be given a unique name (identifier). Variable names are
just the symbolic representation of a memory location.
For Loop:
Unlike the while loop and do…while loop, the for loop contains the initialization,
condition, and updating statements as part of its syntax. It is mainly used to traverse
arrays, vectors, and other data structures.
Flowchart:
ALGORITHM:
1. Start
2. Declare an integer variable to give input for square root, square, checking for prime,
factorial, prime factors calculation.
3. Declare an integer variable to store the output value.
4. Perform square root, square operation and store result into another variable.
5. Declare a flag variable to set the initial value=0.
6. If input number is 0 and 1 then flag set to 1 and display it is prime no.
7. If n is divisible by i, then n is not prime.
8. If n is not divisible by i then n is prime.
9. calculate fact=fact * i
10. Use the condition as if (num % i == 0) then display prime no.
11. Display the result.
12. End
Code:
#include <stdio.h>
#include <math.h>
int main()
{
double number, squareRoot;
scanf("%lf", &number);
return 0; }
// OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ gcc squareeroot.c -o squareeroot -lm
admin1@admin1-ThinkCentre-M92p:~$ ./squareeroot
Enter a number: 36
The square root of 36.00 is 6.00
B) Square Of Number:
#include <stdio.h>
int main()
{
int number, square;
scanf("%d", &number);
return 0; }
// OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch squaree.c admin1@admin1-
ThinkCentre-M92p:~$ gcc squaree.c -o squaree
admin1@admin1-ThinkCentre-M92p:~$ ./squaree
Enter a number: 25
The square of 25 is 625
C) Cube Of Number:
#include <stdio.h>
int main()
{
double number, cube;
scanf("%lf", &number);
return 0; }
// OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch cubee.c admin1@admin1-
ThinkCentre-M92p:~$ gcc cubee.c -o cubee admin1@admin1-ThinkCentre-
M92p:~$ ./cubee
Enter a number: 12
The cube of 12.00 is 1728.0
#include <stdio.h>
int main() {
int number, i, isPrime = 1; // Assume number is prime
scanf("%d", &number);
return 0; }
//OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch primeornot.c admin1@admin1-ThinkCentre-
M92p:~$ gcc primeornot.c -o primeornot
admin1@admin1-ThinkCentre-M92p:~$ ./primeornot Enter a number: 56
56 is not a prime number.
E) Factorial Of Number:
#include <stdio.h>
int main()
{ int number;
long long factorial = 1; // Using long long to handle large results
// Input a number from the user
scanf("%d", &number);
return 0; }
//OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch factorial.c admin1@admin1-ThinkCentre-
M92p:~$ gcc factorial.c -o factorial
admin1@admin1-ThinkCentre-M92p:~$ ./factorial Enter a positive
integer: 13 Factorial of 13 is 6227020800.
F) Prime Factors:
#include <stdio.h>
void primeFactors(int number)
{
printf("Prime factors of %d are: ", number);
while (number % 2 == 0) { printf("2 ");
number /= 2;
}
// Check for odd factors from 3 to sqrt(number)
for (int i = 3; i * i <= number; i += 2) {
while (number % i == 0) { printf("%d ", i);
number /= i;
}
}
// This condition is to check if number is a prime number greater than 2
if (number > 2) {
printf("%d ", number);
}
printf("\n");
} int main() { int number;
// Input a number from the user
printf("Enter a number: "); s
canf("%d", &number);
primeFactors(number);
return 0;
}
// OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch prime_no.c admin1@admin1-
ThinkCentre-M92p:~$ gcc prime_no.c -o prime_no
admin1@admin1-ThinkCentre-M92p:~$ ./prime_no
Enter a number: 60
Prime factors of 60 are: 2 2 3 5
Rajgad Dnyanpeeth’s
S.No.237,Satara-Pune,NH-4,Dhangawadi,Tal:Bhor,Dist:Pune(Maharashtra)
Date of Performance:
Signature of staff with date
TITLE: To accept from the user the number of Fibonacci numbers to be generated
and print the Fibonacci series.
OUTCOMES:
After this experiment, students will acquire knowledge of decision control structures in
python and its application.
THEORY:
Fibonacci numbers in the following integer sequence, called the Fibonacci sequence:
0,1,1,2,3,5,8,13,21,34,55,89,144…..
The first two numbers in the Fibonacci sequence are 0 and 1 and each subsequent number is
the sum of the previous two. Mathematically Fn = Fn-1 + Fn-2
F2 = F0 + F1 = 0+1=1
F3 = F1 + F2 = 1+1=2
F4 = F2 + F3 = 2+1=3
F5 = F3 + F4 = 2+3=5 likewise
ALGORITHM:
Step 1: start
Step 2: declare f1,f2,f3,n,i
Step3: initialize f1=0,f2=1
Step 4: accept the value of n from user
Step 5: print values of f1 and f2
Step 6: for i=2 to n
Step 7:f3=f2+f1
Step 8: print the value of f3
Step 9: assign f2 to f1 and f3 to f2
Step 10:end for
Step 11: stop
FLOWCHART:
CONCLUSION:
2. To accept from user the number of Fibonacci numbers to be generated and print the
Fibonacci series:
#include <stdio.h>
int main() {
int i, n;
// initialize first and second terms
int t1 = 0, t2 = 1;
// initialize the next term (3rd term)
int nextTerm = t1 + t2;
// get no. of terms from user
printf("Enter the number of terms: \n ");
scanf("%d", &n);
// print the first two terms t1 and t2
printf("Fibonacci Series: %d, %d, ", t1, t2);
// print 3rd to nth terms
for (i = 3; i <= n; ++i) {
printf("%d \n", nextTerm);
t1 = t2;
t2 = nextTerm;
nextTerm = t1 + t2;
}
return 0;
}
//Output:-
Enter the number of terms:
3
Fibonacci Series: 0, 1, 1
Rajgad Dnyanpeeth’s
S.No.237,Satara-Pune,NH-4,Dhangawadi,Tal:Bhor,Dist:Pune(Maharashtra)
Date of Performance:
Signature of staff with date
TITLE:To accept an object mass in kilograms and velocity in meters per second and display its
Momentum. Momentum is calculated as e=mc2 where m is the mass of the object and c is its velocity:
OBJECTIVES:
1. To study Decision control statements
2.To understand double keyword .
OUTCOMES:
After this experiment, students will acquire knowledge of calculating the speed of a
light.
THEORY:
This equation holds for a body or system, such as one or more particles, with total energy E,
invariant mass m0, and momentum of magnitude p; the constant c is the speed of light. It assumes
the special relativity case of flat spacetime and that the particles are free. Total energy is the sum
of rest energy and relativistic kinetic energy:Invariant mass is mass measured in a center-of-
momentum frame. For bodies or systems with zero momentum, it simplifies to the mass–energy
equation , where total energy in this case is equal to rest energy
Code-
#include <stdio.h>
#define SPEED_OF_LIGHT 299792458 // Speed of light in meters per second
int main() {
double mass; // Mass in kilograms
printf("Enter mass in kg: ");
scanf("%lf", &mass);
return 0;
}
//Output
Enter mass in kg: 2
Energy (E) = 179751035747363520.000000 Joules.
Rajgad Dnyanpeeth’s
S.No.237,Satara-Pune,NH-4,Dhangawadi,Tal:Bhor,Dist:Pune(Maharashtra)
Date of Performance:
Signature of staff with date
OBJECTIVES:
1. To study Decision control statements
2. To understand and apply if-else and for statements.
OUTCOMES:
The ‘data type’ in the declaration refers to the type of each element in
the array. ‘array_name’ refers to the name by which the memory
locations will be identified. ‘MAX_SIZE’ indicates the maximum
number of elements that can be stored in the array.
Index: 0 1 2 3 4
The number of memory locations required to hold an array depends on its type
and size. For a one dimensional array, its total size is,
Total Size=Size of array*Size of (array data type).
In above declaration, size of array ‘a’ is 5*2=10 bytes.
Array Initialization
ALGORITHM:
1. Declare an Array with size, key and element found, sum, avg
variable. 2. Enter the size of array and no of elements in array
3. Enter the key element to be searched.
4. Compare the key element with every element
5. if element matched then display element found and if not then
display element not found.
6. Perform addition of all elements.
7. Perform an average of it.
8. Display sum and average both.
Code:-
#include <stdio.h>
int main() {
int array[100], n, search, i;
int found = 0; // Flag to indicate if the element is found
// Input the number of elements in the array
printf("Enter the number of elements in the array: ");
scanf("%d", &n);
// Input the elements of the array
printf("Enter %d elements:\n", n);
for (i = 0; i < n; i++) {
scanf("%d", &array[i]);
}
// Input the element to search for
printf("Enter the element to search for: ");
scanf("%d", &search);
// Search for the element in the array
for (i = 0; i < n; i++) {
if (array[i] == search) {
printf("Element %d found at index %d.\n", search, i);
found = 1; // Set the flag to indicate that the element was found
break; // Exit the loop once the element is found
}
}
if (!found) {
printf("Element %d not found in the array.\n", search);
}
return 0;
}
//OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ gccelement.c -o element
admin1@admin1-ThinkCentre-M92p:~$ ./element
Enter the number of elements in the array: 10 12 13 15 18 19 20
Enter 10 elements:
10 12 15 17 18 12 14 15 19 16
Enter the element to search for: Element 18 found at index 3.
admin1@admin1-ThinkCentre-M92p:~$ gccelement.c -o element
admin1@admin1-ThinkCentre-M92p:~$ ./element
Enter the number of elements in the array: 10 12 15 20 18 90 40 50 42 30
Enter 10 elements:
1235620749
Enter the element to search for: Element 2 not found in the array.
#include <stdio.h>
int main() {
int array[100], n, i;
int max, min;
// Input the number of elements in the array
printf("Enter the number of elements in the array: ");
scanf("%d", &n);
// Input the elements of the array
printf("Enter %d elements:\n", n);
for (i = 0; i < n; i++) {
scanf("%d", &array[i]);
}
// Initialize max and min to the first element of the array
max = min = array[0];
// Loop through the array to find max and min
for (i = 1; i < n; i++) {
if (array[i] > max) {
max = array[i];
}
if (array[i] < min) {
min = array[i];
}
}
// Print the results
printf("Maximum element: %d\n", max);
printf("Minimum element: %d\n", min);
return 0;
}
//OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch max_min_ele.c
admin1@admin1-ThinkCentre-M92p:~$ gccmax_min_ele.c -o max_min_ele
admin1@admin1-ThinkCentre-M92p:~$ ./max_min_ele
Enter the number of elements in the array: 12 14 52 56 14 89 45 62 45 20
Enter 12 elements:
12 14 52 78 47 45 85 46 25 36 12 0
Maximum element: 89
Minimum element: 12
#include <stdio.h>
int main() {
int array[100], n, search, frequency = 0;
// Input the number of elements in the array
printf("Enter the number of elements in the array: ");
scanf("%d", &n);
// Input the elements of the array
printf("Enter %d elements:\n", n);
for (int i = 0; i < n; i++) {
scanf("%d", &array[i]);
}
// Input the element to find the frequency of
printf("Enter the element to find its frequency: ");
scanf("%d", &search);
// Calculate the frequency of the element
for (int i = 0; i < n; i++) {
if (array[i] == search) {
frequency++;
}
}
// Print the frequency
if (frequency > 0) {
printf("Element %d occurs %d times in the array.\n", search, frequency);
} else {
printf("Element %d is not present in the array.\n", search);
}
return 0;
}
//OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch frquency_ele.c
admin1@admin1-ThinkCentre-M92p:~$ gccfrquency_ele.c -o frquency_ele
admin1@admin1-ThinkCentre-M92p:~$ ./frquency_ele
Enter the number of elements in the array: 12 14 52 62 85 47 92 60 32 10 11 45
Enter 12 elements:
12 14 52 62 85 47 92 60 32 10 11 45
Enter the element to find its frequency: Element 14 occurs 1 times in the array.
#include <stdio.h>
int main() {
int n, i;
float num[100], sum = 0.0, avg;
printf("Enter the numbers of elements: ");
scanf("%d", &n);
while (n > 100 || n < 1) {
printf("Error! number should in range of (1 to 100).\n");
printf("Enter the number again: ");
scanf("%d", &n);
}
for (i = 0; i < n; ++i) {
printf("%d. Enter number: ", i + 1);
scanf("%f", &num[i]);
sum += num[i];
}
avg = sum / n;
printf("Average = %.2f", avg);
return 0;
}
//OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch average_ele.c
admin1@admin1-ThinkCentre-M92p:~$ gccaverage_ele.c -o average_ele
admin1@admin1-ThinkCentre-M92p:~$ ./average_ele
Enter the numbers of elements: 5
1. Enter number: 10
2. Enter number: 20
3. Enter number: 30
4. Enter number: 40
5. Enter number: 50
Average = 30.00
Rajgad Dnyanpeeth’s
S.No.237,Satara-Pune,NH-4,Dhangawadi,Tal:Bhor,Dist:Pune(Maharashtra)
Date of Performance:
Signature of staff with date
TITLE: Write a C program for employee salary calculation given, Basic, H.R.A.
20% Basic and D.A. 150 % of Basic.
OBJECTIVES:
1. To study Decision Control Statements
2. To understand and apply if and else statements.
OUTCOMES:
THEORY:
ALGORITHM:
1. Declare all variables da, hra, gross.
2. Enter the salary from the user.
3. Perform calculation on basic salary when HRA is 20% and DA is 150%.
4. Calculate gross salary.
5. Display gross salary.
CONCLUSION:
S.No.237,Satara-Pune,NH-4,Dhangawadi,Tal:Bhor,Dist:Pune(Maharashtra)
Date of Performance:
Signature of staff with date
EXPERIMENT NO: 6
TITLE: To accept a student's marks for five subjects, compute his/her result.
Student is passing if he/she scores marks equal to and above 40 in each course. If
student scores aggregate greater than 75%, then the grade is distinguished. If
aggregate is 60>= and <75 then the Grade of first division. If aggregate is 50>= and
<60 then the grade is second division. If aggregate is 40>= and <50 then the grade is
third division.
OBJECTIVES:
1. To study Decision Control Statements
2. To understand and apply an if-else statement.
OUTCOMES:
THEORY:
if (condition) {
// code to be executed if the condition is true
}
if-else Statement:
The if-else statement is a decision-making statement that is used to decide whether the
part of the code will be executed or not based on the specified condition (test
expression). If the given condition is true, then the code inside the if block is executed,
otherwise the code inside the else block is executed.
Syntax of if-else:
if (condition) {
// code executed when the condition is true
}
else {
// code executed when the condition is false
}
if-else-if Ladder in C
Theif else if statementsare used when the user has to decide among multiple options. The
C if statements are executed from the top down. As soon as one of the conditions
controlling the if is true, the statement associated with that if is executed, and the rest of
the C else-if ladder is bypassed. If none of the conditions is true, then the final else
statement will be executed. if-else-if ladder is similar to the switch statement.
Syntax of if-else-if Ladder
if (condition)
statement;else if
(condition)
statement;
.
.
elsestatement;
3. Check the condition if marks >75 and marks <60 then it is distinction.
4. Check the condition if marks >60 and marks <50 then it is first class.
5. Check the condition if marks >50 and marks <40 then it is second class.
CONCLUSION:
Thus, we have successfully compute the marks and display its grade using decision
control statement.
Code:-
#include <stdio.h>
int main() {
float marks[5];
float total = 0.0;
float average;
int passing = 1; // Flag to check if the student is passing
int subjects = 5;
// Input marks for each subject
printf("Enter marks for %d subjects:\n", subjects);
for (int i = 0; i < subjects; i++) {
printf("Subject %d: ", i + 1);
scanf("%f", &marks[i]);
// Check if the student is passing in each subject
if (marks[i] < 40) {
passing = 0;
}
// Calculate total marks
total += marks[i];
}
// Calculate average
average = total / subjects;
// Determine grade
char *grade;
if (average > 75) {
grade = "Distinction";
} else if (average >= 60) {
grade = "First Division";
} else if (average >= 50) {
grade = "Second Division";
} else if (average >= 40) {
grade = "Third Division";
} else {
grade = "Fail";
}
// Display results
printf("\n--- Result Summary ---\n");
printf("Total Marks: %.2f\n", total);
printf("Average Marks: %.2f\n", average);
printf("Grade: %s\n", passing ? grade : "Fail");
return 0;
}
//OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch practical6.c
admin1@admin1-ThinkCentre-M92p:~$ gcc practical6.c -o practical6
admin1@admin1-ThinkCentre-M92p:~$ ./practical6
Enter marks for 5 subjects:
Subject 1: 75
Subject 2: 63
Subject 3: 52
Subject 4: 90
Subject 5: 70
--- Result Summary ---
Total Marks: 350.00
Average Marks: 70.00
Grade: First Division
Rajgad Dnyanpeeth’s
RAJGAD DNYANPEETH TECHNICAL CAMPUS
S.No.237,Satara-Pune,NH-4,Dhangawadi,Tal:Bhor,Dist:Pune(Maharashtra)
Date of Performance:
Signature of staff with date
Title: To accept two numbers from the user and compute the smallest divisor
and Greatest Common Divisor of these two numbers.
OUTCOMES:
THEORY:
This assignment will read the number and perform different operations on
that number.GCD stands for Greatest Common Divisor and is also known as
HCF (Highest Common Factor). The GCD of two numbers is the largest
positive integer that completely divides both numbers without leaving a
remainder.
Variable:
In programming, a variable is a container (storage area) to hold data. To indicate the storage
area, each variable should be given a unique name (identifier). Variable names are just the
symbolic representation of a memory location.
For Loop:
Flowchart:
Algorithm:
CONCLUSION:
Thus, we have successfully calculated GCD and LCM in C using decision control
statements.
Code:-
#include <stdio.h>
// Function to find the smallest divisor greater than 1
int smallest_divisor(int num) {
for (int i = 2; i<= num / 2; i++) {
if (num % i == 0) {
return i; // Return the smallest divisor
}
}
return num; // If no divisor found, the number is prime
}
// Function to find the GCD using the Euclidean algorithm
int gcd(int a, int b) {
while (b != 0) {
int temp = b;
b = a % b;
a = temp;
}
return a; // GCD
}
int main() {
int num1, num2;
// Input two numbers
printf("Enter two numbers: ");
scanf("%d %d", &num1, &num2);
// Calculate smallest divisors
int divisor1 = smallest_divisor(num1);
int divisor2 = smallest_divisor(num2);
// Calculate GCD
int gcd_value = gcd(num1, num2);
// Display results
printf("\n--- Results ---\n");
printf("Smallest divisor of %d: %d\n", num1, divisor1);
printf("Smallest divisor of %d: %d\n", num2, divisor2);
printf("GCD of %d and %d: %d\n", num1, num2, gcd_value);
return 0;
}
//OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch practical7.c
admin1@admin1-ThinkCentre-M92p:~$ gcc practical7.c -o practical7
admin1@admin1-ThinkCentre-M92p:~$ ./practical7
Enter two numbers: 58 63
--- Results ---
Smallest divisor of 58: 2
Smallest divisor of 63: 3
GCD of 58 and 63: 1
Rajgad Dnyanpeeth’s
RAJGAD DNYANPEETH TECHNICAL CAMPUS
S.No.237,Satara-Pune,NH-4,Dhangawadi,Tal:Bhor,Dist:Pune(Maharashtra)
Date of Performance:
Signature of staff with date
TITLE: Write a C program that accepts a string from the user and performs the
following string operations- i. Calculate length of string ii. String reversal iii.
Equality check of two Strings iii. Check palindrome ii. Check substring
OBJECTIVES:
1. To understand different types of built in functions.
2. To understand different syntax of built in functions..
OUTCOMES:
THEORY:
The C string functions are built-in functions that can be used for various operations
and manipulations on strings. These string functions can be used to perform tasks
such as string copy, concatenation, comparison, length, etc. The <string.h>header
file contains these string functions.
String Functions in C
1.strlen() Function
Thestrlen() functioncalculates the length of a given string. It doesn’t count the null
character ‘\0’.
Syntax
int strlen(const char *str);
2. strcmp() Function
3strchr() Function
Thestrchr() function in Cis a predefined function used for string handling. This function is
used to find the first occurrence of a character in a string.Syntax
char *strchr(const char *str, int c);
4 strrev() Function
It is a built-in function in C and is defined in string.h header file. The strrev() function is
used to reverse the given string.
Syntax:
char *strrev(char *str);
Algorithm:
#include <stdio.h>
int main() {
char str[100]; // Declare an array to hold the string
int length = 0; // Initialize length counter
// Prompt the user for input
printf("Enter a string: ");
fgets(str, sizeof(str), stdin); // Read a string from the user
// Calculate the length of the string
while (str[length] != '\0') {
// Check for the newline character added by fgets
if (str[length] == '\n') {
break;
}
length++;
}
// Output the length of the string
printf("The length of the string is: %d\n", length);
return 0;
}
//OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch string_length.c
admin1@admin1-ThinkCentre-M92p:~$ gccstring_length.c -o string_length
admin1@admin1-ThinkCentre-M92p:~$ ./string_length
Enter a string: 12 15 14 18
The length of the string is: 11
#include <stdio.h>
#include <string.h>
int main() {
char str[100]; // Declare an array to hold the string
char reversed[100]; // Array to hold the reversed string
int length, i;
// Prompt the user for input
printf("Enter a string: ");
fgets(str, sizeof(str), stdin); // Read a string from the user
// Remove the newline character added by fgets if present
length = strlen(str);
if (str[length - 1] == '\n') {
str[length - 1] = '\0';
length--; // Update length to exclude the newline
}
// Reverse the string
for (i = 0; i< length; i++) {
reversed[i] = str[length - 1 - i];
}
reversed[length] = '\0'; // Null-terminate the reversed string
// Output the reversed string
printf("Reversed string: %s\n", reversed);
return 0;
}
//OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch string_rev.c
admin1@admin1-ThinkCentre-M92p:~$ gccstring_rev.c -o string_rev
admin1@admin1-ThinkCentre-M92p:~$ ./string_rev
Enter a string: 12 25 23 24 46 47
Reversed string: 74 64 42 32 52 21
#include <stdio.h>
#include <string.h>
int main() {
char str1[100]; // Declare an array to hold the first string
char str2[100]; // Declare an array to hold the second string
// Prompt the user for the first string
printf("Enter the first string: ");
fgets(str1, sizeof(str1), stdin); // Read the first string
// Remove the newline character added by fgets if present
str1[strcspn(str1, "\n")] = '\0'; // This removes the newline character
// Prompt the user for the second string
printf("Enter the second string: ");
fgets(str2, sizeof(str2), stdin); // Read the second string
// Remove the newline character added by fgets if present
str2[strcspn(str2, "\n")] = '\0'; // This removes the newline character
// Check for equality of the two strings
if (strcmp(str1, str2) == 0) {
printf("The strings are equal.\n");
} else {
printf("The strings are not equal.\n");
}
return 0;
}
//OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch string_equ.c
admin1@admin1-ThinkCentre-M92p:~$ gccstring_equ.c -o string_equ
admin1@admin1-ThinkCentre-M92p:~$ ./string_equ
Enter the first string: 12 14 15 16 32
Enter the second string: 14 52 12 58 75
The strings are not equal.
iv. Check palindrome:
#include <stdio.h>
#include <string.h>
int main() {
char str[100]; // Declare an array to hold the string
int length, i, isPalindrome = 1; // Initialize variables
return 0;
}
//OUTPUT:
admin1@admin1-ThinkCentre-M92p:~$ touch palindrome.c
admin1@admin1-ThinkCentre-M92p:~$ gccpalindrome.c -o palindrome
admin1@admin1-ThinkCentre-M92p:~$ ./palindrome
Enter a string: 52 12 18 96 32
The string is not a palindrome.