Ari  Bogisich

Ari Bogisich

1596339000

C++ program to check whether a String is a Pangram or not

Given string str, the task is to check whether a string is pangram or not using in C++.

string is a Pangram if the string contains all the English alphabet letters.

Examples:

Input: str = “We promptly judged antique ivory buckles for the next prize”

_Output: _Yes

_Explanations: _In the above string, str has all the English alphabet letters.

Input: str = “We promptly judged antique ivory buckles for the prize”

_Output: _No

Method-1: Without using STL

This approach is based on Hashing.

  1. A Hashing data structure of boolean type is created of size 26, such that index 0 represents the character ‘a’, 1 represents the character ‘b’ and so on.
  2. Traverse the string character by character and mark the particular character as present in the Hash.
  3. After complete traversal and marking of the string, traverse the Hash and see if all characters are present, i.e. every index has true. If all are marked, then return true, else False.

Below is the implementation of the above approach:

// C++ Program to check if the given 
// string is a pangram or not 

#include <bits/stdc++.h> 
using namespace std; 

// Returns true if the string is 
// pangram else false 
bool checkPangram(string& str) 
{ 
	// Create a hash table to mark 
	// the characters 
	// present in the string 
	vector<bool> mark(26, false); 

	// For indexing in mark[] 
	int index; 

	// Traverse all characters 
	for (int i = 0; i < str.length(); i++) { 

		// If uppercase character, 
		// subtract 'A' to find index. 
		if ('A' <= str[i] && str[i] <= 'Z') 
			index = str[i] - 'A'; 

		// If lowercase character, 
		// subtract 'a' to find index. 
		else if ('a' <= str[i] 
				&& str[i] <= 'z') 
			index = str[i] - 'a'; 

		// If this character is not 
		// an alphabet, skip to next one. 
		else
			continue; 

		mark[index] = true; 
	} 

	// Return false 
	// if any character is unmarked 
	for (int i = 0; i <= 25; i++) 
		if (mark[i] == false) 
			return (false); 

	// If all characters were present 
	return (true); 
} 

// Driver Code 
int main() 
{ 
	string str = "We promptly judged"
				" antique ivory"
				" buckles for the next prize"; 

	if (checkPangram(str) == true) 
		printf("Yes"); 
	else
		printf("No"); 

	return (0); 
}

#c++ #hash #strings #stl #programming-c #cplusplus

What is GEEK

Buddha Community

C++ program to check whether a String is a Pangram or not
Ari  Bogisich

Ari Bogisich

1596339000

C++ program to check whether a String is a Pangram or not

Given string str, the task is to check whether a string is pangram or not using in C++.

string is a Pangram if the string contains all the English alphabet letters.

Examples:

Input: str = “We promptly judged antique ivory buckles for the next prize”

_Output: _Yes

_Explanations: _In the above string, str has all the English alphabet letters.

Input: str = “We promptly judged antique ivory buckles for the prize”

_Output: _No

Method-1: Without using STL

This approach is based on Hashing.

  1. A Hashing data structure of boolean type is created of size 26, such that index 0 represents the character ‘a’, 1 represents the character ‘b’ and so on.
  2. Traverse the string character by character and mark the particular character as present in the Hash.
  3. After complete traversal and marking of the string, traverse the Hash and see if all characters are present, i.e. every index has true. If all are marked, then return true, else False.

Below is the implementation of the above approach:

// C++ Program to check if the given 
// string is a pangram or not 

#include <bits/stdc++.h> 
using namespace std; 

// Returns true if the string is 
// pangram else false 
bool checkPangram(string& str) 
{ 
	// Create a hash table to mark 
	// the characters 
	// present in the string 
	vector<bool> mark(26, false); 

	// For indexing in mark[] 
	int index; 

	// Traverse all characters 
	for (int i = 0; i < str.length(); i++) { 

		// If uppercase character, 
		// subtract 'A' to find index. 
		if ('A' <= str[i] && str[i] <= 'Z') 
			index = str[i] - 'A'; 

		// If lowercase character, 
		// subtract 'a' to find index. 
		else if ('a' <= str[i] 
				&& str[i] <= 'z') 
			index = str[i] - 'a'; 

		// If this character is not 
		// an alphabet, skip to next one. 
		else
			continue; 

		mark[index] = true; 
	} 

	// Return false 
	// if any character is unmarked 
	for (int i = 0; i <= 25; i++) 
		if (mark[i] == false) 
			return (false); 

	// If all characters were present 
	return (true); 
} 

// Driver Code 
int main() 
{ 
	string str = "We promptly judged"
				" antique ivory"
				" buckles for the next prize"; 

	if (checkPangram(str) == true) 
		printf("Yes"); 
	else
		printf("No"); 

	return (0); 
}

#c++ #hash #strings #stl #programming-c #cplusplus

Abdullah  Kozey

Abdullah Kozey

1617695702

Learning C: Input and Output and Two Program Templates

Before I get too deep into C, I need to show you how to get data into and out of your programs. Using assignment for data gets old after a while and you want to be able to have users enter their own data. And you definitely need to be able to see what happens to your data in a program so learning how to display data to the screen is important and necessary.

Besides demonstrating how to perform input and output in C, I will also be demonstrating two templates that are related to those topics — Prompt, Then Read and Input, Process, Output (IPO). The IPO template, in particular, is important because practically every C program you write will use this template.

When I talk about input and output in C, I’ll use the terms standard input and standard output. These terms refer to the default input and output devices on your computer. The standard input device is the keyboard. The standard output device is the computer’s monitor or screen. I will only use the terms input and output and when I use those terms I’m referring to standard input and standard output. If I want to refer to a different device for input and/or output, I’ll use the specific term for that device.

#c-programming-language #c-programming #c-program #c-programming-help

Ari  Bogisich

Ari Bogisich

1589821800

WASI Development Toolchain for C/C++

We realized that compiling already existing C/C++ projects to WASI was much more challenging than we expected. This is because of two main reasons:

  1. It’s not trivial to install and use the WASI SDK
  2. It’s quite hard to port existing projects to WASI as it requires a tighter integration with all configuration and make tools

Inspired by these challenges we have been working non-stop on improving the tooling so it’s easier for anyone to use and adopt WebAssembly and WASI!

#programming #c-programming #c #c# #c++

Anil  Sakhiya

Anil Sakhiya

1607339640

C programming for Beginners | Learn C Programming | C Language

C Language is an evergreen language and is used widely across different industries, This C programming is a must for students and working professionals to become a great Software Engineer especially when they are working in Software Development Domain. Great Learning brings you this live session on “Introduction to C”. In this live session, we will be covering major concepts in C Programming such as Different Variables, Different Data Types that are being used, its Operators, Flow control statements, Structure, and lot more.

#c #programming #developer #c-programming #c-language

Shaylee  Lemke

Shaylee Lemke

1589791833

Object Oriented Programming in C++ | C++ OOPs Concepts | Learn Object Oriented C++

C++ is general purpose, compiled, object-oriented programming language and its concepts served as the basis for several other languages such as Java, Python, Ruby, Perl etc.

The goal of this course is to provide you with a working knowledge of C++. We’ll start with the basics, including syntax, operators, loops, and functions. This Course will explain you how to use data structures and create your own Functions. This Course will show you the details of the powerful object and template systems so you can create useful classes and objects.

Youtube channel: ProgrammingKnowledge - https://www.youtube.com/watch?v=_SH1T3y_D7o

#c #c# #c++ #programming-c