C :: Find Number Of Capital Letters And Punctuations In A String
Jan 28, 2015
write a C program which repeatedly reads in sentences from the user and reports on how many capital letters are in the sentence and how many punctuation characters. Your program will stop asking for input once the user has entered in a blank line. Consider the following example usage with the program. User input is marked in underline:
Enter a sentence: John and Mary went to Fred's house.
You used 3 capital letters and 2 punctuation characters.
Enter a sentence: I like A&W more than McDonald's.
You used 5 capital letters and 3 punctuation characters.
Enter a sentence:
Good bye!
Hint: make use of the standard C functions ispunct and isupper. Other requirements. You must make two functions.
Make a function called find_characters, which has a return type of void, and which has three parameters: one of type char * (a string to find characters in), one of type int * (a reference to int variable indicating how many capital letters are in the string) and the last one also of type int * (a reference to an int variable indicating how many punctuation characters are in the string). Your find_characters function should scan the string and update the two variables it has references to.Make a main function.
This function should repeatedly read in a string from the user, call your find_characters function, and output the information returned to it by the find_characters function indicating how many capital letters and how many punctuation characters were in the string. Your main function should stop reading in input when the user enters in a blank string (i.e., the user just hits enter without entering anything else in). You may assume that the user will not enter in a sentence longer than 100 characters
Code:
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
int main(void) {
[Code] .....
View 9 Replies
ADVERTISEMENT
Mar 27, 2013
How can I write program that can convert an input string into a form that only the first letter of the string is a capital letter and the rest is lower-case?
View 3 Replies
View Related
Sep 26, 2013
I am writing a code that requires the user to input either B or b for bright or D or d for dim. Basically, B is bright and D is dim but I have to code the program such that it allows for both he capital letter and the lowercase letter to be recognized.
View 1 Replies
View Related
Jul 4, 2013
Provide three menu options to format the text entered in QTextEdit to
(1) display the letters in capital letters
(2) display the text in red
(3) align the text in the center
I did the 2nd and the 3rd part but I can't find the capital letter part
Code:
if (name == "Color") {
textEdit->setTextColor("red");
}
if (name == "Capital") {
textEdit->??????;
}
if (name == "Center") {
textEdit->setAlignment(Qt::AlignHCenter);
}
View 2 Replies
View Related
Jun 5, 2013
I'm working on a problem in which I've to design a program in which the punctuations should be removed from the string. For eg., if input str is: "Hello!!"; the output must be: "Hello".
I'm not sure how to remove a sub-string (if that's the right word!!) from a string. So, I designed a program which print out the punctuations. For eg., if input str is: "Hey!!"; the output would be: ! !
Here it is:
#include <iostream>
#include <string>
using namespace std;
int main (){
cout << "Enter a string" << endl;
[Code] ....
So, I want to know what should be added to this program so that the punctuations can be removed; or should I rewrite another program for that?
View 1 Replies
View Related
Dec 10, 2014
Write a program that inputs a string and then converts each 1st letter of a word in the string into capital case. An example run of the program is shown below:
Enter string: introduction to programming
Output string: Introduction To Programming
View 1 Replies
View Related
Feb 27, 2014
I am trying to make a program into which you writre for example ten Names or words or etc. and it would find the longest name/word write it and the numbers of characters too but I have problem with displaying that name. Here is me source code, the problem is here "vitaz=szInput;" i don't know how to save that longest name/word.
#include <cstdlib>
#include <iostream>
#include <string.h>
using namespace std;
int main () {
char a;
char szInput[256],vitaz[256];
[Code] .....
View 5 Replies
View Related
Mar 20, 2014
Just wrote this extremely simple program but it seems to be malfunctioning. It counts correctly the number of uppercase letters in a string so long as i don't use the space-bar. once I add a space it only counts the number of uppercase letters of the first word..
printf("I ..........ing love programming");
Code:
#include <stdio.h>
main()
{
char text[200];
int i = 0;
int uppercase = 0;
printf("Enter text:");
scanf("%s", text);
[code]....
View 6 Replies
View Related
Dec 20, 2014
Write a c++ program to count no of letters in a given line
Write a c++ program to calculate employee salary
validation : for the salary less than 5000
a. HRA IS 15% OF BASIC salary
b. DA is 35% of basic salary
for salary above 5000
a. HRA is 5% of basic salary
b. DA is 25% of basic salary
View 7 Replies
View Related
Apr 10, 2014
I try to use "rand" to create 100 string, I'm happy I succeed, but next step i wanna know how to count each number of letters and the frequency it shows.
Here is the code:
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <iostream>
// using namespace std;
int main() {
const char *c = "abcdefghijklmnopqrstuvwxyz";
[Code] ......
View 1 Replies
View Related
Mar 6, 2015
I'm doing error checks in C and I'd like to know how to restrict the input of a string to 2 letters and if it is exceeded, i'd like to loop and ask for the code to be re-entered.
Code:
for (i = 0; i < code7; i++)
{
printf("Enter number of items: ");
scanf("%d", &item_qty[i]);
[Code].....
View 2 Replies
View Related
May 5, 2014
I am creating a program where I count all the letters of the alphabet from a user submitted string.
How would I go about this?
I am completely new, so simplicity is best. I am suppose to use arrays.
View 4 Replies
View Related
May 1, 2014
My problem says: Have the user enter a number from 1-80 then print out a string of random letters(a to z lowercase) of that length.
I have been able to enter the number and output the correct amount of letters but i can't figure out how to get them to be in a random order and not in alphabetical. Here is what I have so far.
#include <iostream>
using namespace std;
int main() {
int i=0;
int num;
cout<<"How many letters do yu want in your random string?";
[Code]....
View 1 Replies
View Related
Dec 9, 2013
I'm having trouble trying to turn a word into letters. I've seen other posts but they deal with a sentence and it only outputs the words only. What I want to know is how do they take a word (Ex: "word") and break it into individual letters, where I want to store them in a vector of string?
If it's not too much trouble, I would prefer without using pointers or "std:: " marks, since I am trying to avoid pointers and I'm using "using namespace std" all the time.
Ex:
In the example "word", it should output into:
"w"
"o"
"r"
"d"
and I will push them back into a vector of string where each vector element contains a letter.
View 2 Replies
View Related
May 5, 2014
I have to code a simple program who determining the number of Characters (A character could be any alphabets, digits, punctuation marks, or special , Operators ( Operators are those symbols that are used in mathematica expression, such as,'+', '*', '/', '-', and so on.), Uppercase letters (Uppercase characters are those from A..Z) and Numerical digits ( A digit is any of the Hindu-Arabic numerals from 0..9). Why the output is wrong!
#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
#include <iomanip>
using namespace std ;
int main() {
char text;
[Code] .....
This is my input file This is a possible factorial function in a programming language called LISP
(defun factorial (n)
(if (< n 2)
1
(* n (factorial (1- n)))))
This is my output:
The number of characters = 113
The number of operators = 3
The number of numerical digits = 3
Uppercase letters = 5
I think that "characters" is wrong, but I do not know why !
View 4 Replies
View Related
Aug 12, 2013
I've to use recursion function that return if the string has a same letters:
for example: - fff = true
- fFf = false
I did this but the return answer is always: NOT!
bool iSameLetters(char str[SIZE]) {
if(str[0]='