Ye 1 program ka solve kr do.. C
Write a programe to Find Ascii value of a Character please help me
Ye 1 program ka solve kr do.. C
Write a programe to Find Ascii value of a Character please help me
Program to Print ASCII Value
------------
#include <stdio.h>
int main()
{
char c;
printf("Enter a character: ");
// Reads character input from the user
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;
}
Output
---------
Enter a character: G
ASCII value of G = 71
In this program, user is asked to enter a character which is stored in variable c. The ASCII value of that character is stored in variable c rather than that variable itself.
When %d format string is used, 71 (ASCII value of 'G') is displayed.
When %c format string is used, 'G' itself is displayed.
an other porgram
C Program to find ASCII Value of a Character
In this program, User is asked to enter any character and this program will display the ASCII value of that character.
CODE
/* C Program to find ASCII Value of a Character */
#include <stdio.h>
int main()
{
char ch;
printf("\n Please Enter any character \n");
scanf("%c",&ch);
printf("\n The ASCII value of given character = %d",ch);
return 0;
}
C Program to find ASCII value of all Characters
This program will print ASCII values of all the characters currently present.
CODE
/* C Program to find ASCII Value of a Character */
#include <stdio.h>
int main()
{
int i;
for(i=0;i<=255;i++)
{
printf("The ASCII value of %c = %d\n",i,i);
}
return 0;
}
C Program to find Sum of ASCII value in a String
This program allows the user to enter any valid string and then, this program will display the ASCII value of each individual character present in that string and calculate the Sum of all those ASCII values.
CODE
#include <stdio.h>
#include <string.h>
void main()
{
int i, sum = 0, length;
char name[50];
printf("\nPlease Enter any name You wish\n");
scanf("%s", name);
while(name[i]!='\0')
{
printf("\nThe ASCII value of the Character %c = %d\n",
name [i], name [i]);
sum = sum + name [i];
i++;
}
printf("\nSum of all characters : %d ", sum);
}
ممبر کا مسلہ شاید حل ہو چکا ہے اتنا عرصہ گزرے کے بعد
Bookmarks