1 - WAP to replace each string of one or more blanks by a single blank
Description:
Input string:
Pointers are sharp knives.
Output String:
Pointers are sharp knives.
Blank can be spaces or tabs. (replace with single space).
Pr-requisites:-
Functions
Pointers
Objective: -
To understand the concept of
Functions, Arrays, and Pointers
Inputs: -
String with multi-spaces between words
Sample execution: -
Test Case 1:
Enter the string with more spaces in between two words
Pointers are sharp knives.
Pointers are sharp knives.
Test Case 2:
Enter the string with more spaces in between two words
Welcome to Emertxe
Welcome to Emertxe
Test Case 1:
Enter the string with more spaces in between two words
Welcome to Emertxe
Welcome to Emertxe
requested file
#include <stdio.h>
void replace_blank(char []);
int main()
{
char str[50];
printf("Enter the string with more spaces in between two words\n");
scanf("%[^\n]", str);
replace_blank(str);
printf("%s\n", str);
}
2.
2 - WAP to check given string is Pangram or not
Description:
Read a string from the user. Check whether the string is Pangram or not
A pangram is a sentence containing every letter in the English Alphabet.
Example 1 : "The quick brown fox jumps over the lazy dog ” is a Pangram [Contains all the characters from ‘a’ to ‘z’]
Example 2: “The quick brown fox jumps over the dog” is not a Pangram [Doesn’t contain all the characters from ‘a’ to ‘z’, as ‘l’, ‘z’, ‘y’ are missing]
Pre-requisites:
Strings
Functions
Pointers
Input:
Read a string from the user(use selective scanf)
Output:
Print whether the string is Pangram or not
Sample Execution:
Test Case 1:
Enter the string: The quick brown fox jumps over the lazy dog
The Entered String is a Pangram String
Test Case 2:
Enter the string: The quick brown fox jumps over the dog
The Entered String is not a Pangram String
requested file
#include <stdio.h>
int pangram(char []);
int main()
{
}
【General guidance】The answer provided below has been developed in a clear step by step manner.Step1/1The C language code for the problem statement.#include #include #include void replace_blank(char str[]){ int i, j; int n = strlen(str); for (i = 0; i < n; i++) { if (str[i] == ' ' || str[i] == '\t') { for (j = i + 1; j < n; j++) { if (str[j] != ' ' && str[j] != '\t') { break; } } if (j > i + 1) { strcpy(&str[i + 1], &str[j]); n -= j - i - 1; } } }}int pangram(char str[]){ int alphabet[26] = {0}; int i, len = strlen(str); char c; for (i = 0; i < len; i++) { c ... See the full answer