Fpractical Nocd 4
Fpractical Nocd 4
Approved by AICTE ,New Delhi, Govt .of Maharashtra & Affiliated to RTM Nagpur
Practical No -4 Date
Aim: To analyze the given string by determining its length and applying string
manipulation techniques to reverse it using C programming.
Objective:To implement a C program that calculates the length of a given string and
reverses it using standard string functions.
Libraries Required:
Tools Required:
Theory
2.Reversing a String:
Reversing a string involves swapping characters from the beginning with characters
from the end until the middle of the string is reached. This can be done using:
Explanation of code
Text processing
Data validation
Encryption and decryption
String pattern matching
Program
Necessary Code
#include <stdio.h>
#include <string.h>
str[length - i - 1] = temp;
int main() {
char str[100];
str[strcspn(str, "\n")] = 0;
reverseString(str);
return 0;
Output
Course Outcome PO
CO1 PO1,PO2,(sample)
Program Outcome
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO 9 PO10 PO11 PO12
CO 1 1
Conclusion: The program successfully determines the length of the input string and
reverses it using a loop, demonstrating basic string manipulation in C.
Viva - Voce
5.Why do we use gets(str) to take string input, and what is its drawback?