Online Courses
Free Tutorials  Go to Your University  Placement Preparation 
Goeduhub's Online Courses @ Udemy in Just INR 570/-
Online Training - Youtube Live Class Link
0 like 0 dislike
75 views
in Tutorial & Interview questions by Goeduhub's Expert (8.3k points)

Goeduhub's Top Online Courses @Udemy

For Indian Students- INR 570/- || For International Students- $12.99/-

S.No.

Course Name

 Coupon

1.

Tensorflow 2 & Keras:Deep Learning & Artificial Intelligence

Apply Coupon

2.

Natural Language Processing-NLP with Deep Learning in Python Apply Coupon

3.

Computer Vision OpenCV Python | YOLO| Deep Learning in Colab Apply Coupon
    More Courses

1 Answer

0 like 0 dislike
by Goeduhub's Expert (8.3k points)
 
Best answer

 C programming language was invented by Dennis Ritchie at the Bell Laboratories in 1972.  C was invented to write an operating system called UNIX. C programming is considered as the base for other programming languages, that is why it is known as mother language.

  • Easy to learn

  • Structured language

  • It produces efficient programs

  • It can handle low-level activities

  • It can be compiled on a variety of computer platforms

  • It is widely used in the software development field

Execution of C Program 

C is a compiled language. A compiler is a special tool that compiles the program and converts it into the object file which is machine readable. After the compilation process, the linker will combine different object files and creates a single executable file to run the program.  Flow given below-


Writing a source Code --->Compiling a source code --->Linking Object-files

(test.c)                                (test.obj or test.o)                  (test.exe)


Structure of a C Program

Include header file section 

Global declaration section 

main()

{

Declaration part

Executable part

}

User-defined functions

{

Statements

}


  • C program depends upon some header files for function the definition that is used in the program. Each header file by default is extended with .h. The header file should be included using # 
  • Some variables that are used in more than one function. These variables are known as global variables. This section must be declared outside of all the functions.
  • Every program written in C language must contain main () function. The function main() is a starting point of every C program. The execution of the program always begins with the function main (). 

First C Program, open the C console and write the following code:

#include <stdio.h>    

int main(){    

/* My First C Program */

printf("Hello World");    

return 0;   

}  

  •  Header #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.
  • The next line /*...*/ will be ignored by the compiler and it has been put to add additional comments in the program. So such lines are called comments in the program.
  • printf() The printf() function is used to print data on the console. The message "Hello World" to be displayed on the screen.
  • 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 C Program 

Type 1- First install gcc compiler and then save code in a file like "first.c"

  • Open a command prompt and go to the directory where you have saved the file.

  • Type gcc first.c and press enter to compile your code

  • If  code is error free, the command prompt will take you to the next line and would generate a.out executable file.
  • Now, type a.out to execute your program. You will see the output "Hello World" printed on the screen.

$ gcc hello.c
$ ./a.out
Hello World

Type-2 If you are working in Turbo C++ IDE  or in DeV C then,

By menu, 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, press ctrl+f9 keys compile and run the program directly.

You will see the output on user screen. 

You can view the user screen any time by pressing the alt+f5 keys.

Now press Esc to return to the turbo c++ console.

3.3k questions

7.1k answers

393 comments

4.5k users

Related questions

0 like 0 dislike
1 answer 109 views
0 like 0 dislike
1 answer 107 views
0 like 0 dislike
1 answer 155 views
0 like 0 dislike
1 answer 128 views
0 like 0 dislike
1 answer 104 views

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
...