Question

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 properties of the input.
Since characters are integers you will determine the average character (average when
one looks at the character as an integer (its ASCII value). To achieve this you will need
to compute the sum of the ASCII values of the characters.
We are interested in determining the following statistics
1. The number of lowercase alphabetical characters
2. The number of low digits ‘0’,’1’, ‘2’, ‘3’, ‘4’
3. The total number of characters inputted
4. The number of line feeds (ASCII value of 10)
5. The average character (here we treat the characters as an integer based on their
ASCII values) and output the average (do not include ‘X’)
6. The average digit that is read
7. Number of times current character inputted equals preceding character inputted
(b) You will write a main that declares an array of size 100. In the main you will call one
function. It is
int readData(int aR[ ]);
The function readData is such that using a while loop will read integers from the
keyboard and store them in the array aR (that is passed to the function). The while loop
will be controlled by an identifier called flag. Our goal is to limit ourselves to three digit
integers greater than 100.
The loop will be controlled by an integer identifier called flag which is initialized to be 1.
While the flag is one we do the following:
while(flag==1)
{
…..
}
Read an integer
For each read, which is performed by scanf, we will check to see if an integer was read.
• If an integer is not read then we will break out of the loop.
• If the integer read is >= 1000 then we set the flag to 0 and do not insert the
integer in the array.
• If the integer is less than or equal to 100 then we will skip the data and so we do
not insert the integer in the array, but do continue the loop.
Remember to count the number of integers assigned to the array and return this to the
main
You then need to output the integers in the array on main

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

thanks for the question, Please post one question at a time. AS per Chegg policy, I am instructed to answer the first part,

I have coded question a, please post question b as a separate post and i will be assisting you in that.

Here is the code on C.

Let me know for any questions or for any further help !

=======================================================================

#include<stdio.h>

int main(){

               

               

                char letter;

                int lowercase_letters=0;

                int low_digits=0;

                int total_characters=0;

                int line_feed_count=0;

                double total_character_size=0;

               

                printf("Enter characters enter X to quit:\n");

                while(1){

                                scanf("%c",&letter);

                                if(letter=='X')break;

                                else if('a'<=letter && letter<='z')lowercase_letters+=1;

                                else if('0'<=letter && letter<='4')low_digits+=1;

                                else if(letter==10)line_feed_count+=1;

                               

                                total_characters+=1;

                                total_character_size+=int(letter);

                               

                }

               

                if(total_characters>0){

                printf("\n1. The number of lowercase alphabets = %d\n",lowercase_letters);

                printf("2. The number of low digits [0-4] = %d\n",low_digits);

                printf("3. Total number of character = %d\n",total_characters);

                printf("4. Total line feeds = %d\n",line_feed_count);

                printf("5. Average character = %.2lf\n",total_character_size/total_characters);

                               

                }

               

}

=======================================================================

Add a comment
Know the answer?
Add Answer to:
In basic c develop the code below: (a) You will write a program that will do...
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
  • In C programming please (b) You will write a program that will do the following: prompt...

    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 the characters until reading the letter 'O' You will compule 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 'Q' Example input mJ0*5/1+x1@3qcxQ The 'Q' should be included when computing the statistics properties of the input....

  • 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...

  • 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...

  • 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...

  • Need this in C The starter code is long, if you know how to do it...

    Need this in C The starter code is long, if you know how to do it in other way please do. Do the best you can please. Here's the starter code: // ----------------------------------------------------------------------- // monsterdb.c // ----------------------------------------------------------------------- #include #include #include // ----------------------------------------------------------------------- // Some defines #define NAME_MAX 64 #define BUFFER_MAX 256 // ----------------------------------------------------------------------- // Structs typedef struct { char name[NAME_MAX]; int hp; int attackPower; int armor; } Character; typedef struct { int size; Character *list; } CharacterContainer; // ----------------------------------------------------------------------- //...

  • This is for C++ Write a program that reads in a sequence of characters entered by...

    This is for C++ Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along with the number of times it occured. All non-alphabetic characters must...

  • In C code 1. Write and submit the algorithm OR flowchart to indicate you understand the...

    In C code 1. Write and submit the algorithm OR flowchart to indicate you understand the problem 2. Create a project and name the source code lastname_firstname_prog5.c 3. Use the prog5.c as a guide, copy/ paste into your project source code *** build run and test, the outline code - You will need to declare an integer variable called again and initialize it 4. Add the function prototype and implement the function definition for the Greeting function 5. Add 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()...

  • IN C language Write a C program that prompts the user to enter a line of...

    IN C language Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr andcreadLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate...

  • 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