0% found this document useful (0 votes)
21 views

Day 3 Coding Solutions

The document provides code examples in C, C++, Java, and Python to write a program that takes a character as input from the user, determines the ASCII value of that character, and outputs the value. For each language, it shows how to use functions like scanf(), cin, Scanner, and ord() to get character input, convert it to an integer for its ASCII value, and print the result.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Day 3 Coding Solutions

The document provides code examples in C, C++, Java, and Python to write a program that takes a character as input from the user, determines the ASCII value of that character, and outputs the value. For each language, it shows how to use functions like scanf(), cin, Scanner, and ord() to get character input, convert it to an integer for its ASCII value, and print the result.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Talent Battle 100 Days Coding Series

Write a program to find ASCII values of a character

Description

Get an input character from the user and the give the ASCII value of the given input as the output.

Input

Output

98

Input

Output

66

C Program

#include <stdio.h>

int main()

char c;

printf("Enter a character: ");

scanf("%c",&c);

printf("The ASCII value of inserted character is %d",c);

return 0;

}
Talent Battle 100 Days Coding Series

C++ Program

#include <iostream>

using namespace std;

int main()

char c;

cout<<"Enter a character: ";

cin>>c;

cout<<"The ASCII value of inserted character is "<<(int)c;

return 0;

Java Program

import java.util.Scanner;

public class Main

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

System.out.print("Enter a Character: ");

char c=sc.next().charAt(0);

int i = c;

System.out.println("The ASCII value of inserted character is "+i);

}
Talent Battle 100 Days Coding Series

Python

c = input('Enter the character :')

value = ord(c)

print("The ASCII value of inserted character is ",value)

You might also like