-----------------------------------------------------------------------------------
---------------------------------------
Code to print the ASCII value of a variable:
#include <stdio.h>
int main() {
char c;
printf("Enter a character: ");
scanf("%c", &c);
// %d displays the integer value of a character
// %c displays the actual character
printf("ASCII value of %c = %d", c, c);
return 0;
}
-----------------------------------------------------------------------------------
-----------------------------------
Activity: find repeat letters in a word
#include <stdio.h>
int main(){
char word[51];
scanf("%s", word);
int n=0;
int i=0;
int j=0;
int swap=0;
int counter=0;
int updt=0;
while (word[n] != '\0'){
n++;
}
for (j=0; j<n-1; j++)
{
for (i=0; i<n-1; i++)
{
if (word[i] > word[i+1])
{
swap=word[i+1];
word[i+1]=word[i];
word[i]=swap;
}
}
}
i=0;
while (word[i] != '\0' )
{
if (word[i]==word[i+1]){
updt++;
}else{
if(updt>=1)
{
counter++;
}
updt=0;
}
i++;
}
printf ("%d", counter);
return 0;
}