Write a program in C++ to accept a string with white spaces like “Good Morning” from the
keyboard and display the same string.
Answers
Answered by
1
#include <stdio.h>
#include<string.h>
int main() {
char *expect = “its night”;
for (int i= 0; i < strlen(expect); i++) { // Main loop
char c; // A variable to store the character
getchar(c); // Reads character from STDIN
if (c !=expect[i]) { // Compares character against what we would expect to happen
fprintf(“Good Morning”);
return 0; // Exits the program
}
}
fprintf(“Good Night”);
return 0;
}
Hope Thi Will Be Helpful For You
Similar questions