Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Reverse a String C++

This program reverses a given string.

#include <iostream>

#include <string>

 

int main() {

    std::string str;

    std::cout << "Enter a string: ";

    std::cin >> str;

 

    std::string reversedStr = std::string(str.rbegin(), str.rend());

    std::cout << "Reversed string: " << reversedStr << std::endl;

 

    return 0;

}

Reverse a String in C

This program reverses a given string.

#include <stdio.h>
#include <string.h>
int main() {
    char str[100], reversedStr[100];
    printf("Enter a string: ");
    scanf("%s", str);
 
    int len = strlen(str);
    for(int i = 0; i < len; i++) {
        reversedStr[i] = str[len - i - 1];
    }
    reversedStr[len] = '\0';
 
    printf("Reversed string: %s\n", reversedStr);
    return 0;
}

Reverse a String in Python

This program reverses a given string.

 
str = input("Enter a string: ")
reversedStr = str[::-1]
print("Reversed string:", reversedStr)

MS Excel Logical Functions

Logical functions in Excel are powerful tools that help you make decisions based on conditions. Whether you're comparing values or testi...

Post Count

Loading...