How to write c programs?

To write the first c program, open the C console and write the following code:

File name : hello.c or hello.cpp

#include <stdio.h>   

int main(){    

printf("Hello C Language");    

return 0;   

}  


#include <stdio.h> includes the standard input output library functions. The printf() function is defined in stdio.h .

int main() The main() function is the entry point of every program in c language.

printf() The printf() function is used to print data on the console.

return 0 The return 0 statement, returns execution status to the OS. The 0 value is used for successful execution and 1 for unsuccessful execution.


How to compile and run the c program :-

There are 2 ways to compile and run the c program, by menu and by shortcut.

By menu :-

Now click on the compile menu then compile sub menu to compile the c program.

Then click on the run menu then run sub menu to run the c program.

By shortcut :-

Or, press ctrl+f9 keys compile and run the program directly.


You can view the user screen any time by pressing the alt+f5 keys. Now press Esc to return to the turbo c++ console.

Compile and Run a C Program :-

Step 1: Locate the TC.exe file and open it. You will find it at location C:\TC\BIN\.
Step 2: File > New (as shown in above picture) and then write your C program
#include<stdio.h>
int main()
{
       printf("hello World!");
       return 0;
}


Step 3: Save the program using F2 (OR file > Save), remember the extension should be ā€œ.cā€. In the below screenshot I have given the name as helloworld.c

Step 4: Compile the program using Alt + F9 OR Compile > Compile

Step 5: Press Ctrl + F9 to Run (or select Run > Run in menu bar ) the C program.

Step 6: Alt+F5 to view the output of the program at the output screen.




Previous Next

Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here


Ittutorial