C Program To Print All ASCII Characters and Value

Lets write a C program to print/display all ASCII characters and its corresponding value / code.

Note: In C programming language, every alphabet, number and symbol has corresponding ASCII value(a integer number representing the character).

Note:
Total number of Character in ASCII is 256 (0 to 255).
0 to 31(total 32 character) is called as ASCII control characters.
32 to 127 character is called as ASCII printable characters.
128 to 255 is called as The extended ASCII codes.

Video Tutorial: C Program To Print All ASCII Characters and Value


[youtube https://www.youtube.com/watch?v=ejZT-bkXqg4]

YouTube Link: https://www.youtube.com/watch?v=ejZT-bkXqg4 [Watch the Video In Full Screen.]

Source Code: C Program To Print All ASCII Characters and Value

#include<stdio.h>

int main()
{
    int count = 0;

    while(count <= 255)
    {
        printf("ASCII value of %c is %d\n\n ", count, count);
        count++;
    }

    return 0;
}

Output
ASCII value of is 0

ASCII value of is 1

ASCII value of is 2

ASCII value of is 3

ASCII value of is 4

ASCII value of is 5

ASCII value of is 6

ASCII value of is 7

ASCII value of is 8

ASCII value of is 9

ASCII value of
is 10

ASCII value of is 11

ASCII value of is 12

is 13

ASCII value of is 14

ASCII value of is 15

ASCII value of is 16

ASCII value of is 17

ASCII value of is 18

ASCII value of is 19

ASCII value of is 20

ASCII value of § is 21

ASCII value of is 22

ASCII value of is 23

ASCII value of is 24

ASCII value of is 25

ASCII value of is 26

ASCII value of is 27

ASCII value of is 28

ASCII value of is 29

ASCII value of is 30

ASCII value of is 31

ASCII value of is 32

ASCII value of ! is 33

ASCII value of is 34

ASCII value of # is 35

ASCII value of $ is 36

ASCII value of % is 37

ASCII value of & is 38

ASCII value of is 39

ASCII value of ( is 40

ASCII value of ) is 41

ASCII value of * is 42

ASCII value of + is 43

ASCII value of , is 44

ASCII value of is 45

ASCII value of . is 46

ASCII value of / is 47

ASCII value of 0 is 48

ASCII value of 1 is 49

ASCII value of 2 is 50

ASCII value of 3 is 51

ASCII value of 4 is 52

ASCII value of 5 is 53

ASCII value of 6 is 54

ASCII value of 7 is 55

ASCII value of 8 is 56

ASCII value of 9 is 57

ASCII value of : is 58

ASCII value of ; is 59

ASCII value of < is 60

ASCII value of = is 61

ASCII value of > is 62

ASCII value of ? is 63

ASCII value of @ is 64

ASCII value of A is 65

ASCII value of B is 66

ASCII value of C is 67

ASCII value of D is 68

ASCII value of E is 69

ASCII value of F is 70

ASCII value of G is 71

ASCII value of H is 72

ASCII value of I is 73

ASCII value of J is 74

ASCII value of K is 75

ASCII value of L is 76

ASCII value of M is 77

ASCII value of N is 78

ASCII value of O is 79

ASCII value of P is 80

ASCII value of Q is 81

ASCII value of R is 82

ASCII value of S is 83

ASCII value of T is 84

ASCII value of U is 85

ASCII value of V is 86

ASCII value of W is 87

ASCII value of X is 88

ASCII value of Y is 89

ASCII value of Z is 90

ASCII value of [ is 91

ASCII value of \ is 92

ASCII value of ] is 93

ASCII value of ^ is 94

ASCII value of _ is 95

ASCII value of ` is 96

ASCII value of a is 97

ASCII value of b is 98

ASCII value of c is 99

ASCII value of d is 100

ASCII value of e is 101

ASCII value of f is 102

ASCII value of g is 103

ASCII value of h is 104

ASCII value of i is 105

ASCII value of j is 106

ASCII value of k is 107

ASCII value of l is 108

ASCII value of m is 109

ASCII value of n is 110

ASCII value of o is 111

ASCII value of p is 112

ASCII value of q is 113

ASCII value of r is 114

ASCII value of s is 115

ASCII value of t is 116

ASCII value of u is 117

ASCII value of v is 118

ASCII value of w is 119

ASCII value of x is 120

ASCII value of y is 121

ASCII value of z is 122

ASCII value of { is 123

ASCII value of | is 124

ASCII value of } is 125

ASCII value of ~ is 126

ASCII value of  is 127

ASCII value of Ç is 128

ASCII value of ü is 129

ASCII value of é is 130

ASCII value of â is 131

ASCII value of ä is 132

ASCII value of à is 133

ASCII value of å is 134

ASCII value of ç is 135

ASCII value of ê is 136

ASCII value of ë is 137

ASCII value of è is 138

ASCII value of ï is 139

ASCII value of î is 140

ASCII value of ì is 141

ASCII value of Ä is 142

ASCII value of Å is 143

ASCII value of É is 144

ASCII value of æ is 145

ASCII value of Æ is 146

ASCII value of ô is 147

ASCII value of ö is 148

ASCII value of ò is 149

ASCII value of û is 150

ASCII value of ù is 151

ASCII value of ÿ is 152

ASCII value of Ö is 153

ASCII value of Ü is 154

ASCII value of ¢ is 155

ASCII value of £ is 156

ASCII value of ¥ is 157

ASCII value of is 158

ASCII value of ƒ is 159

ASCII value of á is 160

ASCII value of í is 161

ASCII value of ó is 162

ASCII value of ú is 163

ASCII value of ñ is 164

ASCII value of Ñ is 165

ASCII value of ª is 166

ASCII value of º is 167

ASCII value of ¿ is 168

ASCII value of is 169

ASCII value of ¬ is 170

ASCII value of ½ is 171

ASCII value of ¼ is 172

ASCII value of ¡ is 173

ASCII value of « is 174

ASCII value of » is 175

ASCII value of is 176

ASCII value of is 177

ASCII value of is 178

ASCII value of is 179

ASCII value of is 180

ASCII value of is 181

ASCII value of is 182

ASCII value of is 183

ASCII value of is 184

ASCII value of is 185

ASCII value of is 186

ASCII value of is 187

ASCII value of is 188

ASCII value of is 189

ASCII value of is 190

ASCII value of is 191

ASCII value of is 192

ASCII value of is 193

ASCII value of is 194

ASCII value of is 195

ASCII value of is 196

ASCII value of is 197

ASCII value of is 198

ASCII value of is 199

ASCII value of is 200

ASCII value of is 201

ASCII value of is 202

ASCII value of is 203

ASCII value of is 204

ASCII value of is 205

ASCII value of is 206

ASCII value of is 207

ASCII value of is 208

ASCII value of is 209

ASCII value of is 210

ASCII value of is 211

ASCII value of is 212

ASCII value of is 213

ASCII value of is 214

ASCII value of is 215

ASCII value of is 216

ASCII value of is 217

ASCII value of is 218

ASCII value of is 219

ASCII value of is 220

ASCII value of is 221

ASCII value of is 222

ASCII value of is 223

ASCII value of α is 224

ASCII value of ß is 225

ASCII value of Γ is 226

ASCII value of π is 227

ASCII value of Σ is 228

ASCII value of σ is 229

ASCII value of µ is 230

ASCII value of τ is 231

ASCII value of Φ is 232

ASCII value of Θ is 233

ASCII value of Ω is 234

ASCII value of δ is 235

ASCII value of is 236

ASCII value of φ is 237

ASCII value of ε is 238

ASCII value of is 239

ASCII value of is 240

ASCII value of ± is 241

ASCII value of is 242

ASCII value of is 243

ASCII value of is 244

ASCII value of is 245

ASCII value of ÷ is 246

ASCII value of is 247

ASCII value of ° is 248

ASCII value of is 249

ASCII value of · is 250

ASCII value of is 251

ASCII value of is 252

ASCII value of ² is 253

ASCII value of is 254

ASCII value of   is 255

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

color Input Type: HTML5

color input type fields expect the user to pick the color from the color palette. Once the user selects the color its corresponding hexadecimal value is being stored in the input field.

form-input-type-color-type-html5

Demo

There are jQuery plugins to accomplish this task, but with HTML5 we need not use any plugins to accomplish this!

HTML file
index.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
< !DOCTYPE html>
<html>
<head>
<title>color Input Type: HTML5</title>
<link href="myStyle.css" rel="stylesheet" />
<script src="myScript.js"></script>
</head>
<body onload="fetch()">
 
<div>
<label for="color">Color pick: </label>
 <input name="color" type="color" id="get" onchange="fetch()"/><br />
<label for="hexa">Hex Code: </label>
 <input name="hexa" type="text" id="put"/><br />
</div>
 
</body>
</html>

Here we have 2 input fields of type color and text respectively. Once the user selects a color from the color palette, the corresponding hexadecimal value is shown in the text input type field.

JavaScript file
myScript.js

1
2
3
4
5
function fetch()
{
var get = document.getElementById("get").value;
document.getElementById("put").value = get;
}

Once the fetch method is called: it fetches the value present in the (color)input field and assigns it to text input field.

CSS file associated with this is same as present at pattern and title Attribute of Form Field: HTML5

Form Input Type – color: HTML5


[youtube https://www.youtube.com/watch?v=MiCOVDrVH44]

YouTube Link: https://www.youtube.com/watch?v=MiCOVDrVH44 [Watch the Video In Full Screen.]



Note: In real production server, you need not use two input fields as shown in this video tutorial. You can simply make use of the color input type and once you submit the form, you’ll get hexadecimal code value in place of the color input field. If you have a large audience still using Internet Explorer or other older browsers, then you can use jQuery plugin to accomplish the same task across all major browsers.

Roots of Quadratic Equation: JavaScript

Quadratic Equations are of the form ax2 + bx + c = 0. To find roots(root1 and root2) of such an equation, we need to use the formula

quadratic-equation


Video Explaining The JavaScript Code To Find Roots of a Quadratic Equation:


[youtube https://www.youtube.com/watch?v=Td6QViKdbZU]

YouTube Link: https://www.youtube.com/watch?v=Td6QViKdbZU [Watch the Video In Full Screen.]


To calculate the roots of a quadratic equation using a computer program, we need to break down the formula and calculate smaller parts of it and then combine to get the actual solution.

So lets calculate square root of b2 – 4 * a * c and store it in variable root_part. Also store 2 * a in variable denom. Now calculate ( – b + root_part ) / denom and store it in root1 and ( – b – root_part ) / denom in root2.
Output the values of root1 and root2 to the browser using document.write statement.

Javascript Coding Explained In Above Video:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 <title>Quadratic Equation</title>
 
 
<script type="text/javascript">
<!--
var a = prompt("Enter value of a","1");
var b = prompt("Enter value of b","4");
var c = prompt("Enter value of c","4");
 
var root_part = Math.sqrt(b * b - 4 * a * c);
var denom = 2 * a;
 
var root1 = ( -b + root_part ) / denom;
var root2 = ( -b - root_part ) / denom;
 
document.write("1st root: "+root1+"<br />");
document.write("2nd root: "+root2+"<br />");
 
// -->
</script>

Usually people will make mistake in this line

var root_part = Math.sqrt(b * b - 4 * a * c);

Be sure that, you write capital letter M in Math.sqrt.

Work Space:
Quadratic Equation: ax2 + bx + c = 0
Let,
a = 1
b = 4
c = 4
i.e., 1x2 + 4x + 4 =0
=> 1x2 + 2x + 2x + 4 = 0
=> x ( x + 2 ) + 2 ( x + 2 ) = 0
=> ( x + 2 ) + ( x + 2 ) = 0
=> x + 2 = 0 AND x + 2 = 0
=> x = -2 AND x = -2

Generating Fibonacci Series using JavaScript

Today lets see how to generate Fibonacci Series using JavaScript programming.

First Thing First: What Is Fibonacci Series ?
Fibonacci Series is a series of numbers where the first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two. Its recurrence relation is given by Fn = Fn-1 + Fn-2.

Below are a series of Fibonacci numbers(10 numbers):
0
1
1
2
3
5
8
13
21
34

How Its Formed:
0 <– First Number
1 <– Second Number
1 <– = 1 + 0
2 <– = 1 + 1
3 <– = 2 + 1
5 <– = 3 + 2
8 <– = 5 + 3
13 <– = 8 + 5
21 <– = 13 + 8
34 <– = 21 + 13

Video Explaining The JavaScript Code To Generate Fibonacci Series:


[youtube https://www.youtube.com/watch?v=V8WwUwOxm5M]

YouTube Link: https://www.youtube.com/watch?v=V8WwUwOxm5M [Watch the Video In Full Screen.]


Some points to keep in mind:
1. In Javascript, it is not mandatory to declare a variable before using it. But still its a good practice to declare it before using.
2. Using html comments inside javascript code ensures that, the old browsers which do not support javascript will ignore all the code written inside the script tags.
3. If we give a very large number while entering the limit, then the loop start executing and the browser memory will soon exhaust and the browser may stop responding.
4. You can use any valid html coding inside document.write statement, as the output will be then processed by a html browser.

JavaScript Code Shown In Above Video:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 <title>Fibonacci Series</title>
 
<script type="text/javascript">
<!--
 
var var1 = 0;
var var2 = 1;
var var3;
 
var num = prompt("Enter the limit to generate fibonacci no",0);
 
document.write(var1+"<br />");
document.write(var2+"<br />");
 
for(var i=3; i < = num;i++)
{
var3 = var1 + var2;
var1 = var2;
var2 = var3;
 
document.write(var3+"<br />");
}
 
// -->
</script>

In JavaScript:
Variable declaration is done using var keyword, followed by the variable name.
document.write is the output statement.
prompt is used to get the input from the user.

Even though the above program is easy, you may forget the logic when it is needed. So don’t forget to actually pullout a text editor and try it out yourself.