Question

In C programming please

(b) You will write a program that will do the following: prompt the user enter characters from the keyboard, you will read th

0 0
Add a comment Improve this question Transcribed image text
Answer #1

You can save this as HomeworkLib.c

A well commented code for your understanding.

#include <stdio.h>

int main(){
    char str[1000]; // you can change the value of size as per demand
    printf("Enter the characters from the keyboard!:\n");
    scanf("%[^Q]s",str); // this will read until a Q is encountered 
    //Although all the parts can be done in a sinngle loop but i am explaining it part wise
    // lets find the length first part 3
    int i = 0;
    int length=0;
    while(str[i]!='\0'){
        length++;
        i++;
    }
    printf("\nTotal number of characters inputted including 'Q' %d",length+1);
    // part 1 
    i=0;
    int lower = 0;
    while (str[i] != '\0') {
        if (str[i] >= 'a' && str[i] <= 'z')
            lower++;
        i++;
    }
    printf("\nThe number of lowercase characters: %d",lower);
    //part 2
    i=0;
    int even = 0;
    while (str[i] != '\0') {
        if (str[i] >= '0' && str[i] <= '9')
            if(((str[i]-'0')%2)==0)
                even++;
        i++;
    }
    printf("\nThe number of even digits: %d",even);
    //part 4
    i=0;
    int linefeed = 0;
    while (str[i] != '\0') {
        if (str[i] ==10)
            linefeed++;
        i++;
    }
    printf("\nThe number of line feeds: %d",linefeed);
    // you can do all the four in one line by simply putting the if conditions in a single while
    
    return 0; 
}

// now you can run this using on Linux terminal using

gcc HomeworkLib.c 
./a.out

// you can run this using on Windows shell using

gcc HomeworkLib.c
.\a.exe

Output:

. PS C:\Users\risha OneDrive\Desktop\Codes> . \a.exe Enter the characters from the keyboard!: mJ&*5/1+x1@3qcxQ Total number o

Hope this helped you. Now you can solve all related problems.

Add a comment
Know the answer?
Add Answer to:
In C programming please (b) You will write a program that will do the following: prompt...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using c++ ) You will write a program that will do the following: prompt the user...

    Using c++ ) You will write a program that will do the following: prompt the user enter characters from the keyboard you will read the characters until reading the letter O' You will compute statistics concerning the type of characters entered. In this lab we will use a while loop. We will read characters from stdin until we read the character ' Example inpu mJ0*5/tx1@3qcx0 The 'Q'should be included when computing the statistics properties of the input. Since characters are...

  • In basic c develop the code below: (a) You will write a program that will do...

    In basic c develop the code below: (a) You will write a program that will do the following: prompt the user enter characters from the keyboard, you will read the characters until reading the letter ‘X’ You will compute statistics concerning the type of characters entered. In this lab we will use a while loop. We will read characters from stdin until we read the character ‘X’. Example input mJ0*5/]+x1@3qcxX The ‘X’ should not be included when computing the statistics...

  • To be turned in You will write a program that will do the following: Prompt the...

    To be turned in You will write a program that will do the following: Prompt the user to enter any character form the keyboard. You will compute some statistic concerning the type of characters entered. You will keep reading characters until a 'Q' is entered. The 'Q' should not be included when computing the statistics properties of the input. Example input: $8mJ0*5/I+Nx1@3qc2XQ We are interested in determining the following statistics: The number of alphabets The number of uppercase letters The...

  • In this program, you will be using C++ programming constructs, such as overloaded functions. Write a...

    In this program, you will be using C++ programming constructs, such as overloaded functions. Write a program that requests 3 integers from the user and displays the largest one entered. Your program will then request 3 characters from the user and display the largest character entered. If the user enters a non-alphabetic character, your program will display an error message. You must fill in the body of main() to prompt the user for input, and call the overloaded function showBiggest()...

  • Assembly Programming Question. Read keystroke, reverse case and display, stop on ESC. Also relevant: Also relevant:...

    Assembly Programming Question. Read keystroke, reverse case and display, stop on ESC. Also relevant: Also relevant: Also relevant (though you cant use Irvine16.inc): Assembly Programming Question. Read keystroke, reverse case and display, stop on ESC. Assembly Programming Question. Read keystroke, reverse case and display, stop on ESO. 3. Write a program that reads a user keystroke and if it?s an alphabetical character, reverses it case then displays it. The program should stop when the user hits the ESC key (1Bh)....

  • C programming (not c++) This programs input is a series of words. All words consist of...

    C programming (not c++) This programs input is a series of words. All words consist of only lowercase letters(a-z), no uppercase letters or digits or punctuation or other special symbols. The program reads until end-of-file, and then prints out the lowercase letters that were not seen in the input. Enter your input: the quick brown fox jumps over the lazy old dog Missing letters: enter your input: roll tide missing letters: a b c f g h j k m...

  • C++ please! In this program you will be outputting the characters that map to the ASCIl...

    C++ please! In this program you will be outputting the characters that map to the ASCIl codes 32 through 126. You will need a loop to iterate through the input values and output the corresponding character. This mapping is shown in appendix A in your Gaddis text book. Your program will be reading in two unsigned integer values. The prompt for read will be Enter lower and upper values You need to check that both values are in the range...

  • MIPS programming question Problem 1: Write a program that asks the user to input a string...

    MIPS programming question Problem 1: Write a program that asks the user to input a string (or no more than 50 characters). Your program should then output the length of the string. The string length should be determined using a separate function strlen that will accept the address of the string and return its length. For the purposes of this exercise, the length of a string will be defined as the number of non-null and non-newline characters until either the...

  • You're to write a C++ program that analyzes the contents of an external file called data.txt....

    You're to write a C++ program that analyzes the contents of an external file called data.txt. (You can create this file yourself using nano, that produces a simple ASCII text file.) The program you write will open data.txt, look at its contents and determine the number of uppercase, lowercase, digit, punctuation and whitespace characters contained in the file so that the caller can report the results to stdout. Additionally, the function will return the total number of characters read to...

  • I need eclipse code for : Write a program that analyzes text written in the console...

    I need eclipse code for : Write a program that analyzes text written in the console by counting the number of times each of the 26 letters in the alphabet occurs. Uppercase and lowercase letters should be counted together (for example, both ‘A’ and ‘a’ should count as an A). Any characters that are not letters should be ignored. You must prompt the user to enter the text to be analyzed. Then, for any letter that appeared at least once...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT