Programa para imprimir alfabetos de A a Z usando Loop
A tarefa é imprimir os alfabetos de A a Z usando um loop .
No programa abaixo, o loop for é usado para imprimir os alfabetos de A a Z. Uma variável de loop é usada para fazer isso do tipo 'char'. A variável de loop 'i' é inicializada com o primeiro alfabeto 'A' e incrementada em 1 em cada iteração. No loop, este caractere 'i' é impresso como o alfabeto.
Programa:
// C++ program to find the print
// Alphabets from A to Z
#include <bits/stdc++.h>
using namespace std;
int main()
{
// Declare the variables
char i;
// Display the alphabets
cout << "The Alphabets from A to Z are: \n";
// Traverse each character
// with the help of for loop
for (i = 'A'; i <= 'Z'; i++)
{
// Print the alphabet
cout << i <<" ";
}
return 0;
}
// This code is contributed by
// Shubhamsingh10
// C program to find the print
// Alphabets from A to Z
#include <stdio.h>
int main()
{
// Declare the variables
char i;
// Display the alphabets
printf("The Alphabets from A to Z are: \n");
// Traverse each character
// with the help of for loop
for (i = 'A'; i <= 'Z'; i++) {
// Print the alphabet
printf("%c ", i);
}
return 0;
}
// Java program to find the print
// Alphabets from A to Z
class GFG
{
public static void main(String[] args)
{
// Declare the variables
char i;
// Display the alphabets
System.out.printf("The Alphabets from A to Z are: \n");
// Traverse each character
// with the help of for loop
for (i = 'A'; i <= 'Z'; i++)
{
// Print the alphabet
System.out.printf("%c ", i);
}
}
}
/* This code contributed by PrinciRaj1992 */
# Python3 program to find the print
# Alphabets from A to Z
if __name__ == '__main__':
# Declare the variables
i = chr;
# Display the alphabets
print("The Alphabets from A to Z are: ");
# Traverse each character
# with the help of for loop
for i in range(ord('A'), ord('Z') + 1):
# Print the alphabet
print(chr(i), end=" ");
# This code is contributed by Rajput-Ji
// C# program to find the print
// Alphabets from A to Z
using System;
class GFG
{
public static void Main(String[] args)
{
// Declare the variables
char i;
// Display the alphabets
Console.Write("The Alphabets from A to Z are: \n");
// Traverse each character
// with the help of for loop
for (i = 'A'; i <= 'Z'; i++)
{
// Print the alphabet
Console.Write("{0} ", i);
}
}
}
// This code is contributed by Rajput-Ji
<script>
// Javascript program to find the print
// Alphabets from A to Z
// Declare the variables
let i;
// Display the alphabets
document.write("The Alphabets from A" +
" to Z are: " + "</br>");
// Traverse each character
// with the help of for loop
for(i = 'A'.charCodeAt();
i <= 'Z'.charCodeAt(); i++)
{
// Print the alphabet
document.write(
String.fromCharCode(i) + " ");
}
// This code is contributed by decode2207
</script>
Saída:
The Alphabets from A to Z are: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
As postagens do blog Acervo Lima te ajudaram? Nos ajude a manter o blog no ar!
Faça uma doação para manter o blog funcionando.
70% das doações são no valor de R$ 5,00...
Diógenes Lima da Silva