how can i make this c++ code so i can write \" the quick brown fox\" in the inpu
ID: 3729895 • Letter: H
Question
how can i make this c++ code so i can write " the quick brown fox" in the input instead
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool checkPangram (string &phrase)
{
vector<bool> check(26, false);
int index;
for (int i=0; i<phrase.length(); i++) {
if (phrase[i] >= 'A' && phrase[i] <= 'Z') {
index = phrase[i] - 'A';
} else if(phrase[i] >= 'a' && phrase[i] <= 'z') {
index = phrase[i] - 'a';
}
check[index] = true;
}
for (int i=0; i< 26; i++) {
if (!check[i]) {
return (false);
}
}
return (true);
}
int main()
{
string phrase = "the quick brown fox jumps over the crazy dog !!";
if (checkPangram(phrase)) {
cout << "This is a pangram";
} else {
cout << "This is not a pangram";
}
return 0;
}
Explanation / Answer
Following are two types
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool checkPangram (string &phrase)
{
vector<bool> check(26, false);
int index;
for (int i=0; i<phrase.length(); i++) {
if (phrase[i] >= 'A' && phrase[i] <= 'Z') {
index = phrase[i] - 'A';
} else if(phrase[i] >= 'a' && phrase[i] <= 'z') {
index = phrase[i] - 'a';
}
check[index] = true;
}
for (int i=0; i< 26; i++) {
if (!check[i]) {
return (false);
}
}
return (true);
}
int main()
{
string phrase = "the quick brown fox"; // this is the input string
if (checkPangram(phrase)) {
cout << "This is a pangram";
} else {
cout << "This is not a pangram";
}
return 0;
}
// Output: This is not a pangram
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool checkPangram (string &phrase)
{
vector<bool> check(26, false);
int index;
for (int i=0; i<phrase.length(); i++) {
if (phrase[i] >= 'A' && phrase[i] <= 'Z') {
index = phrase[i] - 'A';
} else if(phrase[i] >= 'a' && phrase[i] <= 'z') {
index = phrase[i] - 'a';
}
check[index] = true;
}
for (int i=0; i< 26; i++) {
if (!check[i]) {
return (false);
}
}
return (true);
}
int main()
{
string phrase;
cout << "Enter a phrase:"; // prompting for user input
getline(cin,phrase); // this line is to take input
if (checkPangram(phrase)) {
cout << "This is a pangram";
} else {
cout << "This is not a pangram";
}
return 0;
}
/* SAMPLE OUTPUT
Enter a phrase: the quick brown fox
This is not a pangram
*/
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool checkPangram (string &phrase)
{
vector<bool> check(26, false);
int index;
for (int i=0; i<phrase.length(); i++) {
if (phrase[i] >= 'A' && phrase[i] <= 'Z') {
index = phrase[i] - 'A';
} else if(phrase[i] >= 'a' && phrase[i] <= 'z') {
index = phrase[i] - 'a';
}
check[index] = true;
}
for (int i=0; i< 26; i++) {
if (!check[i]) {
return (false);
}
}
return (true);
}
int main()
{
string phrase = "the quick brown fox"; // this is the input string
if (checkPangram(phrase)) {
cout << "This is a pangram";
} else {
cout << "This is not a pangram";
}
return 0;
}
// Output: This is not a pangram
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool checkPangram (string &phrase)
{
vector<bool> check(26, false);
int index;
for (int i=0; i<phrase.length(); i++) {
if (phrase[i] >= 'A' && phrase[i] <= 'Z') {
index = phrase[i] - 'A';
} else if(phrase[i] >= 'a' && phrase[i] <= 'z') {
index = phrase[i] - 'a';
}
check[index] = true;
}
for (int i=0; i< 26; i++) {
if (!check[i]) {
return (false);
}
}
return (true);
}
int main()
{
string phrase;
cout << "Enter a phrase:"; // prompting for user input
getline(cin,phrase); // this line is to take input
if (checkPangram(phrase)) {
cout << "This is a pangram";
} else {
cout << "This is not a pangram";
}
return 0;
}
/* SAMPLE OUTPUT
Enter a phrase: the quick brown fox
This is not a pangram
*/
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.