top of page

Beginner In Linux (how to run c program in ubuntu)


As a person is beginner in linux . they face problem in getting thing in proper way.

as in windows (7,8,8.1,10) there is not in rich graphic in linux.

First of all you have to install linux in your computer.

various option is there .

1) make a boot in usb and run linux (ubuntu) without installing it.

2) virtual box .if you don't want to lose your windows then virtual box is very useful for you.

(before installing linux in virtual box see that intel virtualization is ON or

not in BIOS setting )

3) complete install in your computer ( you can watch how to install ubuntu on youtube)

4) dual boot

AFTER THAT IN LINUX DON'T HAVE TO INSTALL DRIVERS OR ANY THING ELSE.

just hit CTRL+T

it open ups terminal .

where you can write commands.

common commands for linux user

1) sudo apt-get update

downloads the package lists from the repositories and "updates" them to get information on the newest versions of packages and their dependencies. It will do this for all repositories and PPAs

2) sudo apt-get upgrade.

will fetch new versions of packages existing on the machine if APT knows about these new versions by way of apt-get update

3) ls for list

4)cd for change directory

5)cd .. back from directory

HOW TO RUN C PROGRAM IN LINUX

1). Write and save the programOpen a simple text editor (e.g gedit), IDE (Eclipse) or command line code editor (Nano or Vim). I’ll be using gedit as it is very simple to use and it’s recommended for beginner programmers. Right Click on Desktop or any directory (Browse File using Nautilus) and select create new File – hello.c (.c extension is used to indicate that it’s a c program). Then write a simple program like this (and save the program press Ctrl+S)

#include<stdio.h>

main()

{

printf("Hello World\n");

/* Do something more if you want */

}

2)Compile the programGCC (GNU Compiler Collection) is installed by default, in Ubuntu. To compile the program, open the terminal and move on to the target directory type the command – (where gcc implies compiler name, then it asks for the file name of the source program while -o option specifies the file name of the output program)

gcc hello.c -o hello1

If there is no syntax/semantic error in you program then the compiler will successfully generate an executable file, otherwise fix the problem in your code.

3)Type the command

./hello

This should result in the output

Hello world


Featured Posts
Recent Posts
Archive
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square

© 2023 by Zoe Marks. Proudly created with Wix.com

bottom of page