Home » , » C First Program

C First Program

 C First Program

In the preceding lesson, we discovered how to set up the surroundings for C. Now, we will see how to run C first program.  It’s pretty easy. Let’s start with launching Turbo C and strolling C first software 

Go To Start > Turbo C

Open Turbo C and open a new project,

Firstly, store it and provide any identify with extension c. Here, we have given the identify Study1.c, 
Now, let’s add a demo program

Let’s work on our first C program,




Here,
#include

It is the preprocessor and the first word read by the compiler

stdio.h
It is the header file.

int main()
main() function with return type int.

printf
Used to print the formatted string to stdout. The standard output is stdout.

return
Terminates the function execution and the return statement returns the control to the calling function.

When you will run the above program, you won’t get an output in Turbo C, but the program runs correctly. To allow the output to be visible on the screen, remove the return statement and add the return type to the main() function as shown below, with getch() method.

Also, add <conio.h> header file and getch() for output to be visible in Turbo C++. The MS-DOS compiler uses the <conio.h> header file to show console input/output.

getch()  is used to read a character from the screen and is added just before the program ends. It is a predefined function in <conio.h> header file. To clear the screen, you can also add clrscr(); just after the declaration.

We’re using the <conio.h> header file and getch() to show output on Turbo C, which is our MS-DOS compiler.

Here’s or final C program,




Here’s our C program on Turbo C compile,
For output, press Ctrl+F9.

The following output is visible,

In this lesson, we learned how to run our first C program in Turbo C. Similarly, create a new file in Turbo C, write C code in it and run it as shown above.

If you liked the tutorial, spread the word and share the link and our website language coding with others.




0 comments:

Post a Comment

Popular Posts

GENRES

 
Copyright ©

latest code update bloggingskillBest coding website in india

Created By Sora Templates | Distributed By Gooyaabi Templates