February 4, 2011

C Program to Print HELLO without HELLO


Here we are going to print HELLO without using any of the later from the HELLO, anywhere in the programing. Just think before proceeding further how we can do this..

Well here is the answer; here we are using ASCII CODE of the character to print HELLO.

ASCII TABLE OF ALPHABETS





Code:

//C program to print HELLO without HELLO
#include<stdio.h>
#include<conio.h>
void main()
{
int a=72,b=69,c=76,d=79;
printf("%c%c%c%c%c",a,b,c,c,d);
getch();
}

Logic of the code:
first you give a try to find the logic..

Here in the code we took integer as data type and given ASCII code of H to a, E to b, L to c and O to d.

Step by step compiler start compiling (saving the code). First it comes to data type. It is int then it comes to printf where Format Specifier of Data Type is CHARCHTER (%C).

Compiler compiling program as integer form where a=72, b=69, c=76, d=79 and when it comes to output part the Format Specifier is character so it converting 72 (number) to character form and hence we get 72 as H and so on..

Also read:

C Program for Multiplication without Using Multiply Operator *

Hope you liked my posts, give comments if you have any doubts.. :)

Related Posts :



Categories: ,

1 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Related Posts with Thumbnails