7.3 ASCII Code
7.3 ASCII Code
[3] Print the Character Variable as a Character and ASCII Code Value.
[4] Print all the Digits with their ASCII Code Value separated by a space, and each digit in a separate line.
[5] Print all the Uppercase Letters with their ASCII Code Values separated by a space, and each letter in a separate line.
[6] Print all the Lowercase Letters with their ASCII Code Values separated by a space, and each letter in a separate line.
[7] Print all the ASCII Characters with their ASCII Code Values.
[8] Input a Character and Print that character and its ASCII Code.
সমাধান
[3] Print the Character Variable as a Character and ASCII Code Value.
#include<stdio.h>
int main(){
char ch = 'A';
printf("Character: %c\n", ch);
printf("ASCII Code: %d\n", ch);
return 0;
}
[4] Print all the Digits with their ASCII Code Value separated by a space, and each digit in a separate line.
#include<stdio.h>
int main(){
char ch;
printf("Char => ASCII\n");
for(ch = '0'; ch <= '9'; ch++) {
printf("%c => %d\n", ch, ch);
}
return 0;
}
[5] Print all the Uppercase Letters with their ASCII Code Values separated by a space, and each letter in a separate line.
#include<stdio.h>
int main(){
char ch;
printf("Char => ASCII\n");
for(ch = 'A'; ch <= 'Z'; ch++) {
printf("%c => %d\n", ch, ch);
}
return 0;
}
[6] Print all the Lowercase Letters with their ASCII Code Values separated by a space, and each letter in a separate line.
#include<stdio.h>
int main(){
char ch;
printf("Char => ASCII\n");
for(ch = 'a'; ch <= 'z'; ch++) {
printf("%c => %d\n", ch, ch);
}
return 0;
}
[7] Print all the ASCII Characters with their ASCII Code Values.
#include<stdio.h>
int main(){
char ch;
printf("Char => ASCII\n");
for(ch = 0; ch < 127; ch++) {
printf("%c => %d\n", ch, ch);
}
return 0;
}
[8] Input a Character and Print its ASCII Code.
#include<stdio.h>
int main(){
char ch;
scanf(" %c", &ch);
printf("Character: %c ASCII Code: %d\n", ch, ch);
return 0;
}
Last updated