Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program that takes characters from user in an array and prints them with their ASCII values without using 'atoi' func

Posted By: Adelfried Fischer     Category: C Programming     Views: 3912

Write a program that takes characters from user in an
array and prints them with their ASCII values. (Do not use 'atoi' function)

Code for Program that takes characters from user in an array and prints them with their ASCII values without using 'atoi' func in C Programming

#include<stdio.h>
#include<conio.h>
void main()
{
    char a[10];
    int i,j,n,a1[10];
    clrscr();
    printf("\n Please Give The Value of N:  ");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        flushall();
        printf("\n enter value of a[%d] :",i);

        scanf("%c",&a[i]);
        a1[i]=a[i];
        printf("\n value of %c = %d ",a[i],a1[i]);

    }
    getch();
}


--------------------------------- OUTPUT ---------------------------------


 Please Give The Value of N:  5

 enter value of a[0] :a

 value of a = 97
 enter value of a[1] :b

 value of b = 98
 enter value of a[2] :c

 value of c = 99
 enter value of a[3] :d

 value of d = 100
 enter value of a[4] :A

 value of A = 65

  
Share: 



Adelfried Fischer
Adelfried Fischer author of Program that takes characters from user in an array and prints them with their ASCII values without using 'atoi' func is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!