Write a C Program to Print the ASCII values of each Character of an Input String

ASCII Values

Basic Intro About ASCII Values:


char is a keyword used to indicate the Character Type Data. The Data may be a Character constant or String Constant. 
  1. A Character Constant may be defined as any single Character enclosed with in a pair of apostrophes. Examples : 'a' , 'd' , 'g' etc. 
  2. A string constant is defined as a sequence of characters placed between double quotes. Examples : "Computer" , "system" , "hello" etc. The string constant is terminated by a null character (\0).

Each Character Constant has an Integer value. The value is Given by the ASCII( American Standard Code For Information Interchange) Character Set. Some of the Character constants and their ASCII values are:


    Character Constant    

            'A' 
            'B' 
            'Z'
            'a'
            'z'
            '0'
            '9'
            '&'
            '='
            '{'

    ASCII Values
 
          65 
          66
          90
          97
         122
          48
          57
          38
          61
         123



    => Statement of C Program : This Program Prints the ASCII values of each Character of an Input String :

    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    char string[20];
    int n, kount=0;
    printf("How many characters ? ");
    scanf("%d" , &n);
    printf(" Enter the string of %d characters\n" , n);
    scanf("%s" , string);
    while( kount<n )
    {
    printf(" %c = %d\n" , string[kount] , string[kount] );
    ++ kount ;
    }                                          /* End of while */
    }                                                                       /* End of main() */

    Remember:
    • ++kount can also be written as kount = kount+1.
    • ++kount indicates pre increment. The value of kount must be increment before it is used ( increment and use).

    Output:
    How many characters ?
    3
    Enter the string of 3 characters
    cat
    c = 99
    a = 97
    t = 116

    0 Response to "Write a C Program to Print the ASCII values of each Character of an Input String"

    Post a Comment

    Popular Posts

    Label

    1 Sidebar 2 Columns 3 Columns Footer 3rdball 4 Columns Footer Alex Alvaro Antsasia Arlinadesign Averie Barry BASIC CONCEPTS Basil Bayna Fast BeautyPress BeautyTemplates Beckel Best Best - Clean Beyonce Pro BioMag BlackMag Blanter Nova Blogger Card Bloggertheme9 Blogish Bpress Brakt C LANGUAGE C PROGRAMS C++ LANGUAGE C++ PROGRAMS Carella Cellar Charlotte Chooko Lite Clara Clean Combo One Cooperate Crusade Darry Dorman Dreamway Dunia Blanter eCars EduAcademy EducationPress Elise Elvan Eva Everyday FabNews Fashion Fashion Blogger Template Fashion Gossip FastCars Fedo FlashNews Fredy Portfolio Gaming Globus GoodTime Goomsite HTML LANGUAGE iGaming Indicate Innove Insomnia InspiredNews iSoft Jasmine Kalem Landscaping Lashira Lavelle Lily Fashion Limax Linea Lionex Luminescence Lite Lumix Luxury Magazine MagazinePro MAJOR DIFFERENCES MarketingBlog Martin MaxiMag Medica Mega Melissa Mercury MeshMag Minimag Minimalist MiniNews MovieKhor msdesignbd MusicLand Neko NetZine New Spread News16 Newsflash NewsForce NewsIdea Newspaper News NewsPro Nubie Fast Odd Themes Optima PaperMag PaperMag blog Parhlo Perfection Personal Personal Blog Photosout PixelZ Power Blog Premium Themes ProfileMag Purez Rano ReadNews Real estate Remito Grid Responsive Revo Robusta Rotario Saara SeoBoost Settle Shouters Simple Catch SimpleClean Sketchly SNews SolidMag Someo Sophie Sora Sora Bank Sora Home Sora News Responsive Sora One Sora Ribbon Spido Sticko Stucco Sure Mag Swift Tech Tech Pro Techia Techmax TechSpot TemplateClue Templateism Templatesilk Templatesyard Templatezy The Freelancer TheBlogger TheFocus Themeforest Themexpose TIPS AND TRICKS Topside TravelMag Trendy Trendy Travel Tumblr Under Construction Uong Jowo Veethemes Vertox VideoPlay Vigo Waverly way2themes WebBiz Wedding X-Mag Zealer ZetaMag