Monday, April 1, 2013

C program to add tab space


Sometimes we need to create some gap at the beginning of a line that is formally name as tab space and we do that using the Tab button during typing in Microsoft Office Word. But to do so in output of a c program we have to use \t command. An example is given below.

#include<stdio.h>
void main(){
   printf("www.iDhali.com\n");
   printf("\t-by Uzzwal Dhali");
}

Output for the Above Codes
www.iDhali.com
-by Uzzwal Dhali

Code Description

1. In the first line I have added the standard input out header file by using the line #include<stdio.h>conio.h and math.h are also two Header files.

2. In the second line there is written void main(). This is the main function of a C program.

void main() {
   all other codes
}

3. In the fourth line there is written printf("www.iDhali.com\n"); That's why the program will output www.iDhali.com after executing the third line. And for the \n after www.iDhali.com will create a new line (as like as we get after pressing the Enter key during typing.

4. In the fifth line there is written printf("\t-by Uzzwal Dhali"); This line will also output the text inside the double quotation (" "), but a tab space will be created before the line.

Advertisement

No comments:

Post a Comment