Wednesday, January 25, 2012

A simple C program to print a line

 This post is for a beginner programmar. It is a simple C program to display a line.

#include<stdio.h>
void main()
    {
    printf("A simple C program\n");
    }

Output:
A simple C program

A program starts executing from the main() function. Here there only 1 line for execution in the main function ie. printf("A simple C program \n");
This statement is used to print the values to the standard output device(monitor).
'\n' is an escape sequence for newline. It set the cursor to the next line.
stdio.h is a header file. It has the definition of the function printf(). That is why we are including it.

If you have understood the program then try to write a program to display your name and address in the below given format
Name
Address line 1
Address line 2
Pincode

3 comments :

  1. all the best dear very thnkful to u fr this blog.

    ReplyDelete
  2. plz find me a solutn to make string to string array in a loop.in java

    ReplyDelete
    Replies
    1. I didnt understand your requirement. plz specify a sample input and output.

      I think this will help you.

      http://ayyostream.blogspot.com/2012/01/string-to-character-array-in-java.html

      Thanks for your response.

      Delete