C Exercises: Display the integer equivalents of letters
C Basic Declarations and Expressions: Exercise-74 with Solution
Write a C program to display the integer equivalents of letters (a-z, A-Z).
Sample Solution:
C Code:
#include<stdio.h>
int main()
{
char* letters = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int n;
printf("List of integer equivalents of letters (a-z, A-Z).\n");
printf("==================================================\n");
for(n=0; n<53; n++) {
printf("%d\t", letters[n]);
if((n+1) % 6 == 0)
printf("\n");
}
return 0;
}
Sample Output:
List of integer equivalents of letters (a-z, A-Z). ================================================== 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
Flowchart:
C programming Code Editor:
Contribute your code and comments through Disqus.
Previous:Write a C program that reads in two integers and check whether the first integer is a multiple of the second integer.
Next: Write a C program that accepts one seven-digit number and separates the number into its individual digits, and prints the digits separated from one another by two spaces each.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
C Programming: Tips of the Day
Static variable inside of a function in C
The scope of variable is where the variable name can be seen. Here, x is visible only inside function foo().
The lifetime of a variable is the period over which it exists. If x were defined without the keyword static, the lifetime would be from the entry into foo() to the return from foo(); so it would be re-initialized to 5 on every call.
The keyword static acts to extend the lifetime of a variable to the lifetime of the programme; e.g. initialization occurs once and once only and then the variable retains its value - whatever it has come to be - over all future calls to foo().
Ref : https://bit.ly/3fOq7XP
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework