How to compile and run a c program in ubuntu and in other UNIX operating systems

   At first you have to create a file and save it in .c extension. Now the file has been saved in the format which this c program can be compiled.Now open the terminal use "gcc" or "cc" compiler for compiling the progam.

   Type:  cc example.c





   Now your file is compiled, it will show error if there is any error otherwise the c program will be converted into object code. Now the object program will be in the extension .out.
   
   The object file will be named as a.out or example.out format. Now you can execute the code as ./a.out or ./example.out



  Now "Enter the first number:" was the output of my c program.
SHARE

Admin

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment