Question

C ONLY Print every other character in the string “The quick brown fox jumps over the...

C ONLY

Print every other character in the string “The quick brown fox jumps over the lazy old dog”

Print only the vowels in the string “The quick brown fox jumps over the lazy old dog”

Count the number of spaces in the string “The quick brown fox jumps over the lazy old dog”

Homework Answers

Answer #1

[1] Print every other character in the string “The quick brown fox jumps over the lazy old dog”

Solution :

#include <stdio.h>
#include <conio.h>


int main()
{
char str[] = "The quick brown fox jumps over the lazy old dog";
char flag = 'N' ;
char cmp;
int i,j;
clrscr();

for( j = 65 ; j < 91 ; j++)
{
cmp =char(j);
flag = 'N';
for( i = 0 ; i < str[i] !='\0' ; ++i)
{
   if(str[i] != cmp)
    {

    }

    else
    {
     flag = 'Y';
     break;
    }

}

if(flag == 'N')
{
   printf(" %c ",cmp);
}

}


for( j = 97 ; j < 123 ; j++)
{
cmp =char(j);
flag = 'N';
for( i = 0 ; i < str[i] !='\0' ; ++i)
{
   if(str[i] != cmp)
    {

    }

    else
    {
     flag = 'Y';
     break;
    }

}

if(flag == 'N')
{
   printf(" %c ",cmp);
}

}


     getch();

    return 0;
}

[2] Print only the vowels in the string “The quick brown fox jumps over the lazy old dog”

#include <stdio.h>
#include <conio.h>
#include <string.h>


int main()
{
char str[] = "The quick brown fox jumps over the lazy old dog";
int i,length;
clrscr();

length = strlen(str);


for( i = 0 ; i < length ; i++)
{
   if(str[i] == 'a' ||
      str[i] == 'e' ||
   str[i] == 'i' ||
   str[i] == 'o' ||
   str[i] == 'u' ||
   str[i] == 'A' ||
   str[i] == 'E' ||
   str[i] == 'I' ||
   str[i] == 'O' ||
   str[i] == 'U'
        )
    {

    printf("%c",str[i]);

           }
}   


     getch();

    return 0;
}

[3] Count the number of spaces in the string “The quick brown fox jumps over the lazy old dog”

#include <stdio.h>
#include <conio.h>


int main()
{
char *str,s[1000] = "The quick brown fox jumps over the lazy old dog";
int i,j, space;


clrscr();

str=s;
    for(space = 0;*str;str++)
       {
            if(*str!= ' ')
              continue;
         space++;
       }
    
printf("%d spaces\n",space);
     getch();
    return 0;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C++: Write a function that receives a pointer to a character string consisting of only alphabets...
C++: Write a function that receives a pointer to a character string consisting of only alphabets a-z and returns the character with the maximum number of repetitions. If more than one-character repeats same number of times, return the character with smallest alphabetical order. For example, the string “Mississippi” has three repeated characters (i-4, s-4, p-2). Both ‘i’ and ‘s’ repeated 4 times but ‘i’ is alphabetically smaller hence the function should return ‘i’. Do not count repeated blanks, special characters,...
This is function.py def processString(string): # Implement this function This is # This should print 4.5...
This is function.py def processString(string): # Implement this function This is # This should print 4.5 3.0 processString("An example. Two") # This should print 4.4 5.3 4.5 processString("This is the first sentence. The second sentence starts after the period. Then a final sentence") Download function.py and complete the processString(string) function. This function takes in a string as a parameter and prints the average number of characters per word in each sentence in the string. Print the average character count per...
def processString(string): # Implement this function # This should print 4.5 3.0 processString("An example. Two") #...
def processString(string): # Implement this function # This should print 4.5 3.0 processString("An example. Two") # This should print 4.4 5.3 4.5 processString("This is the first sentence. The second sentence starts after the period. Then a final sentence") This function takes in a string as a parameter and prints the average number of characters per word in each sentence in the string. Print the average character count per word for each sentence with 1 decimal precision(see test cases below).-Assume a...
C++ only: Please implement a function that accepts a string parameter as well as two character...
C++ only: Please implement a function that accepts a string parameter as well as two character arguments and a boolean parameter. Your function should return the number of times it finds the character arguments inside the string parameter. When both of the passed character arguments are found in the string parameter, set the boolean argument to true. Otherwise, set that boolean argument to false. Return -1 if the string argument is the empty string. The declaration for this function will...
ANSWER IN C++ ONLY A string of characters including only alphabets (lowercase letters) is provided as...
ANSWER IN C++ ONLY A string of characters including only alphabets (lowercase letters) is provided as an input. The first task is to compute the frequency of each character appearing in the string. In the output, the characters have to be arranged in the same order as they appear in the input string. Then characters have to be rearranged, such that all the characters having a specific frequency, say xx, come together. Let the frequency of a character, lying in...
Strings The example program below, with a few notes following, shows how strings work in C++....
Strings The example program below, with a few notes following, shows how strings work in C++. Example 1: #include <iostream> using namespace std; int main() { string s="eggplant"; string t="okra"; cout<<s[2]<<endl; cout<< s.length()<<endl; ​//prints 8 cout<<s.substr(1,4)<<endl; ​//prints ggpl...kind of like a slice, but the second num is the length of the piece cout<<s+t<<endl; //concatenates: prints eggplantokra cout<<s+"a"<<endl; cout<<s.append("a")<<endl; ​//prints eggplanta: see Note 1 below //cout<<s.append(t[1])<<endl; ​//an error; see Note 1 cout<<s.append(t.substr(1,1))<<endl; ​//prints eggplantak; see Note 1 cout<<s.find("gg")<<endl; if (s.find("gg")!=-1) cout<<"found...
This must be answered not advance methods, focusing on String method. We are working on Ch...
This must be answered not advance methods, focusing on String method. We are working on Ch 9 in Think Java 1st Ed.I need the program to be bare bones and the coding need to be done the long way with no advanced code. in this lab you will have two methods with headings: - public static int countNumberSigns(String tweetText) - public static int countHashtags(String tweetText) 'String tweetText' means the method is expectiong a string value as an input to it....
USE C programming (pls label which file is libcipher.h and libcipher.c) Q4) A shift cipher is...
USE C programming (pls label which file is libcipher.h and libcipher.c) Q4) A shift cipher is one of the simplest encryption techniques in the field of cryptography. It is a cipher in which each letter in a plain text message is replaced by a letter some fixed number of positions up the alphabet (i.e., by right shifting the alphabetic characters in the plain text message). For example, with a right shift of 2, ’A’ is replaced by ’C’, ’B’ is...
Python Blackjack Game Here are some special cases to consider. If the Dealer goes over 21,...
Python Blackjack Game Here are some special cases to consider. If the Dealer goes over 21, all players who are still standing win. But the players that are not standing have already lost. If the Dealer does not go over 21 but stands on say 19 points then all players having points greater than 19 win. All players having points less than 19 lose. All players having points equal to 19 tie. The program should stop asking to hit if...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total 52 case sensitive) and five special characters (‘.’, ‘,’, ‘:’, ‘;’ and ‘!’) in all the .txt files under a given directory. The program should include a header count.h, alphabetcount.c to count the frequency of alphabet letters; and specialcharcount.c to count the frequency of special characters. Please only add code to where it says //ADDCODEHERE and keep function names the same. I have also...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT