Question

Write a complete console program in c++ that outputs your entire lower-case English alphabets (26 of...

Write a complete console program in c++ that outputs your entire lower-case English alphabets (26 of them) and their respective numbers in reversed order.

Output should be:

a: 26

b: 25

c: 24

...

x:3

y:2

z:1

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

C++ CODE

#include<iostream>
using namespace std;

int main()
{
   /*THIS CODE CAN BE WRITTEN USING ASCII VALUES*/
   /* ASCII VALUE OF a: 97 and z : 122 */

   char start='a'; // LOOP WILL START FROM
   char end='z'; // LOOP WILL ENDS HERE
   int i; //ITERATE VARIABLE

   // START VARIABLE TYPE CASTED TO INT , WHICH IS 97, AND FOR z : 123
   // SO LOOP WILL ITERATE FROM 97 TO 123

   for (i=(int)start; i<=(int)end; i++)
   {
       // char(i) : CHARACTER VALUE OF INTEGER I, FOR 97 : IT IS "a"
       //FOR CORRESPONDING NUMBER VALUE : int)end-(i-1)
       //FOR START IS "a" : (int)z-(95-1) => 26
       cout<<char(i)<<":"<<(int)end-(i-1)<<endl;
   }
   return 0;

} // MAIN END

SCREENSHOT CODE

#include<iostream> using namespace std; int main() / *THIS CODE CAN BE WRITTEN USING ASCII VALUES*/ /* ASCII VALUE OF a: 97 a

OUTPUT

a:26 b:25 C:24 d:23 e:22 f:21 g:20 h:19 i:18 j:17 k:16 1:15 m:14 n:13 0:12 p:11 9:10 r:9 S:8 333XXN PNWMO

Add a comment
Know the answer?
Add Answer to:
Write a complete console program in c++ that outputs your entire lower-case English alphabets (26 of...
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
  • Write a program that prompts the user to enter a 10 alphabets (A-Z) and converts it...

    Write a program that prompts the user to enter a 10 alphabets (A-Z) and converts it to numbers using the following mapping: A, B, C = 8 D, E, F = 6 G, H, I = 4 J, K, L = 5 M, N, 0 = 7 P, Q, R, S = 2 T, U, V, W = 3 X, Y, Z = 1 Please be sure to use Object Oriented Programming concepts when designing and writing code for this...

  • Write a multithreaded C program that outputs prime numbers. This program should work as follows: the...

    Write a multithreaded C program that outputs prime numbers. This program should work as follows: the user will run the program and will enter a number on the command line. The program will then create a separate thread that outputs all the prime numbers less than or equal to the number entered by the user. ADD  "comments" to the source code please and a screenshot of the output with steps on how to compile

  • C Program In this assignment you'll write a program that encrypts the alphabetic letters in a...

    C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...

  • Write MARIE assembly language programs that do the following: I. Write a program that inputs thre...

    Write MARIE assembly language programs that do the following: I. Write a program that inputs three integers, a, b, and c, in that order. It computes the following ia-bi-fc+ c The result should be written to output 2. Write a program that inputs integers, s. y, and z. It outputs the difference of the langest and first element entered. You may assume x. y, and z all have different values. So if 8, 12, and 9 are input, the output...

  • write a program in C++ Suppose that the alphabets are given the following values: a=1, b=2,...

    write a program in C++ Suppose that the alphabets are given the following values: a=1, b=2, c=3, ..., z=26. Using this rule, we define the value of a word as the sum of the values of its letters. Thus, the value of the word cat is c+a+t = 3+1+20 = 24. Furthermore, the value of the phrase "a cat" is a+c+a+t=1+3+1+20=25. The value of a sentence, paragraph, and any larger unit of writing is similarly defined. When we compute such...

  • (Must be in C#) (Console will be my choice) Create a program called NarwhalCalc that will...

    (Must be in C#) (Console will be my choice) Create a program called NarwhalCalc that will be used to compute a narwhal's weight in tons based on its length in feet. Your program must use a method to do this and you must write this method. Your method must be called FeetToTons and the method must accept a parameter called feet (type double). The method should then use the formula shown below to calculate the narwhal's weight, then RETURN (not...

  • Write a C++ console application that allows your user to capture rainfall statistics. Your program should...

    Write a C++ console application that allows your user to capture rainfall statistics. Your program should contain an array of 12 doubles for the rainfall values as well as a parallel array containing the names of the months. Using each of the month names, prompt your user for the total rainfall for that month. The program should validate user input by guarding against rainfall values that are less than zero. After all 12 entries have been made, the program should...

  • 4. Write a C++ program Write a program that takes as input five numbers and outputs...

    4. Write a C++ program Write a program that takes as input five numbers and outputs the mean (average) and standard deviation of the numbers. If the numbers are xi, Xa, x3, Xa, and xs, then the mean is x = (Xi + X2 + X3+ X4 + Xs)/5 and the standard deviation is: Your program must contain at least the following functions: a function that calculates and returns the mean and a function that calculates the standard deviation. 30...

  • 1. Write a python program that reads a file and prints the letters in increasing order...

    1. Write a python program that reads a file and prints the letters in increasing order of frequency. Your program should convert entire input to lower case and only counts letters a-z. Special characters or spaces should not be counted. Each letter and it's occurrences should be listed on a separate line. 2. Test and verify your program and it's output. ---Please provide a code and a screenshot of the code and output. Thank you. ----

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