This sample program will print Welcome to C programming.
// Sample C program
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
printf(“ Welcome to C programming”);
getch();
return 0;
}
Brief explanation of each line of the program is given below:
(1) // Sample C program
This is a comment line. Comments are used to document the program. It is like a remark from the programmer. They can appear in any part of the program. We write comments for better understanding of the program. The comments are ignored by the compiler. Comments are useful for software maintenance.
(2) #include<stdio.h>
This command includes standard input/output header file, stdio.h from the C library in the program before compiling. The stdio.h file contains functions such as scanf() and printf() to take input and display output respectively. #include is preprocessor directive, and stdio.h is Header file. Header files in C have a .h extension.
The #include directive can be used to include pre-existing header files or user-defined header files. the #include directive tells the preprocessor to include the contents of a specified file at the point where the directive appears. This allows the programmer to import header files into their program and access the functions and methods within them.
(3) #include<conio.h>
This command includes console input/output header file, conio.h from the C library in the program. The conio.h file contains functions such as clrscr() and getch() to clear the output screen and pause the output screen.
(4) int main()
Here main() is the function name and int is the return type of this function. It is a compulsory part of every C program. It is a special function used to inform the compiler that the program starts from there. Execution of every C program starts from main() function. Logically every program must have exactly one main() function.
(5) { and }
The opening curly bracket ‘{’ indicates the beginning of the main function and the closing curly bracket ‘}’ indicates the end of the main function.
(6) clrscr();
clrscr() is a library function (system defined function) used to clear the console screen. It is defined in conio.h header file. Using of clrscr() function in C is always optional . If the function is to be used, then it should be placed after variable or function declaration only.
(7) printf(“Welcome to C programming”) ;
This command tells the compiler to display the message “Welcome to C programming”. printf() is a library function used in C to display the output onto the screen. The text to be printed is enclosed in double quotes.
(8) Use of semicolon “;”
The semicolon serves as the statement terminator. Semicolon character at the end of the statement is used to indicate that the statement is ending there. Each executable statement should have a ‘;’ to inform the compiler that the statement has ended. Thus, in ‘C’ the semicolon terminates each statement.
(9) getch();
getch() function pauses the output console screen until a key is pressed. It is defined in conio.h header file. This function is used to hold the output screen for some time until the user presses a key from the keyboard.
(10) return 0;
The return statement is used to return a value from a function and indicates the finishing of a function. The value ‘0’ means successful execution of this function. This statement is basically used in functions to return the results of the operations performed by a function.
As a Newbie, I am continuously browsing online for articles that can be of assistance to me. Thank you
Great – I should definitely pronounce, impressed with your web site. I had no trouble navigating through all the tabs and related info ended up being truly easy to do to access. I recently found what I hoped for before you know it at all. Quite unusual. Is likely to appreciate it for those who add forums or something, web site theme . a tones way for your customer to communicate. Nice task..
Yay google is my queen helped me to find this great internet site! .
This is very interesting, You’re a very skilled blogger. I have joined your rss feed and look forward to seeking more of your great post. Also, I have shared your web site in my social networks!
What¦s Happening i’m new to this, I stumbled upon this I have discovered It positively helpful and it has helped me out loads. I hope to give a contribution & assist different customers like its helped me. Good job.
Thank you for the sensible critique. Me and my neighbor were just preparing to do some research about this. We got a grab a book from our area library but I think I learned more clear from this post. I’m very glad to see such fantastic info being shared freely out there.
Attractive portion of content. I simply stumbled upon your website and in accession capital to say that I get in fact enjoyed account your blog posts. Anyway I’ll be subscribing to your augment or even I achievement you get admission to persistently rapidly.
It’s actually a great and useful piece of information. I am glad that you just shared this helpful info with us. Please keep us up to date like this. Thanks for sharing.
After study a few of the blog posts on your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Pls check out my web site as well and let me know what you think.
Real great information can be found on site.
I?¦ve learn several good stuff here. Certainly price bookmarking for revisiting. I surprise how so much effort you set to create any such fantastic informative website.
Wow, incredible blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your website is fantastic, as well as the content!
You are my breathing in, I possess few web logs and occasionally run out from to post : (.
You got a very excellent website, Sword lily I noticed it through yahoo.
I’d forever want to be update on new articles on this website , saved to my bookmarks! .
There is noticeably a bundle to know about this. I assume you made certain nice points in features also.
Appreciate it for helping out, excellent info. “Our individual lives cannot, generally, be works of art unless the social order is also.” by Charles Horton Cooley.
Some genuinely interesting details you have written.Aided me a lot, just what I was looking for : D.
Enjoyed looking at this, very good stuff, thankyou.
magnificent put up, very informative. I wonder why the opposite experts of this sector do not understand this. You should continue your writing. I’m sure, you have a huge readers’ base already!
I am so happy to read this. This is the type of manual that needs to be given and not the accidental misinformation that is at the other blogs. Appreciate your sharing this best doc.
Hello my loved one! I wish to say that this article is amazing, nice written and include almost all significant infos. I¦d like to see more posts like this .
There is apparently a lot to realize about this. I consider you made some good points in features also.
I have read a few good stuff here. Certainly price bookmarking for revisiting. I surprise how a lot effort you place to make any such great informative web site.
This web site is really a walk-through for all of the info you wanted about this and didn’t know who to ask. Glimpse here, and you’ll definitely discover it.
Very interesting subject, appreciate it for posting.
Very well written information. It will be helpful to anybody who employess it, as well as me. Keep up the good work – for sure i will check out more posts.
Sweet internet site, super style and design, rattling clean and utilize pleasant.
Very interesting info!Perfect just what I was searching for!
I have not checked in here for some time since I thought it was getting boring, but the last few posts are great quality so I guess I?¦ll add you back to my daily bloglist. You deserve it my friend 🙂
I couldn’t resist commenting
Hey very nice website!! Man .. Excellent .. Amazing .. I’ll bookmark your site and take the feeds also…I am happy to find so many useful info here in the post, we need work out more strategies in this regard, thanks for sharing. . . . . .
Loving the info on this internet site, you have done great job on the articles.
Its like you read my mind! You seem to know so much about this, like you wrote the book in it or something. I think that you could do with a few pics to drive the message home a little bit, but other than that, this is great blog. An excellent read. I’ll definitely be back.
Hello very cool web site!! Guy .. Beautiful .. Wonderful .. I will bookmark your site and take the feeds additionallyKI am satisfied to search out numerous helpful info right here within the publish, we need work out extra strategies on this regard, thank you for sharing. . . . . .
Great wordpress blog here.. It’s hard to find quality writing like yours these days. I really appreciate people like you! take care
Thank you for another excellent article. Where else could anybody get that type of info in such a perfect way of writing? I’ve a presentation next week, and I’m on the look for such info.
I don’t ordinarily comment but I gotta tell appreciate it for the post on this amazing one : D.
I really happy to find this web site on bing, just what I was searching for : D as well bookmarked.
Saved as a favorite, I really like your blog!
I am glad to be one of several visitants on this outstanding site (:, thanks for posting.
We are a bunch of volunteers and starting a new scheme in our community. Your site provided us with valuable info to work on. You’ve done an impressive activity and our entire group shall be grateful to you.
Saved as a favorite, I really like your blog!
I¦ve read a few good stuff here. Definitely worth bookmarking for revisiting. I surprise how so much attempt you place to create this type of great informative site.