74.1k views
0 votes
Write a loop to store the letters “f” through “w” in an array named letters. Then, print the contents of the array to the screen.

1 Answer

3 votes

Answer:

#include<iostream>

#include<conio.h>

using namespace std;

main()

{

char a[18];

int k=102;

for (int j=0; j<18; j++)

{

a[j]=k;

k=k+1;

}

cout<<"The Array of characters between f and W is Given below"<<endl;

for (int l=0;l<18;l++)

{

cout<<a[l]<<endl;

}

getch();

}

Step-by-step explanation:

In this program, list of characters has been printed between f and w using for loop as per requirement. An array has been taken with name a and size 18, as there are 18 elements from f to w. As we know that ASCII code of Small f is 102 in decimal, we store that in another variable k. Start loop and assign ASCII code of each alphabet using 'k' variable to array a. After that array of assigned alphabets has been printed.

User Abdennour TOUMI
by
4.9k points