Friday, 20 December 2013
Print Hello world with out using semi colon in c programming language
Print hello world without using semicolon in c. See how can you do this in c language. in last post we show how to develop a Text To Speech Converter in Java , but we know most of our users much comfortable with c programming language. So lets start exploring c , in this post you will learn very deeply , i bet you will get very useful information regarding c , so enjoy our step by step approach :
Step 1 -
Do You Know -
do you know about printf function properly. NO , actually you dont know , that when you write printf("Hello")
it return an integer value (number of letters) but mostly we don't store it.
Correct syntax : int printf(String str,---)
it returns length of String inside printf function
So for Example - when you write
printf("Hello"); // it return 5
you can store it as -
num = printf("Hello")
and value of num will be 5
Step 2 -
Do You Know -
for if(n) , value of n any thing other than 0 considered as true in c so if there is written as if(11) then it is true in case of c.
Example :
if(11)
printf(" I am in if block");
else
printf(" I am in else block");
Output - I am in if block
Surprised , don‘t worry see next step.
Step 3 - (Final)
Now by using above two steps we can write code now. Code with out semicolon
void main() {
if(printf("Hello World")){ }
if(getch()){ }
}
Output - Hello World
Do You Know -
getch() function waits for users inputs and returns ascii so again if function got true condition.
Like our facebook page for regular updates , Comment for any query !
Sunday, 1 December 2013
Subscribe to:
Posts (Atom)