Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Implement a program to find the longest word in a sentence.

Medium

Problem Statement

Implement a program to find the longest word in a sentence.

Sample Input

std::string sentence = "Find the longest word in this sentence";

Sample Output

Longest word = sentence

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
#include <iostream> #include <sstream> #include <string> int main() { std::string sentence = "Find the longest word in this sentence"; // Logic to find the longest word return 0; }
Log in or sign up to run or submit your code.Log inSign up
Input
std::string sentence = "Find the longest word in this sentence";
Expected Output
Longest word = sentence