0% found this document useful (0 votes)
13 views2 pages

Practical 1

This document outlines the basics of the C programming language and its compilation processes on both Windows and Linux systems. It details the historical background of C, the steps to compile and run a C program in both environments, and provides a simple programming assignment. The conclusion emphasizes the understanding of the compilation process across different operating systems.

Uploaded by

jadhaoshiv3012
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Practical 1

This document outlines the basics of the C programming language and its compilation processes on both Windows and Linux systems. It details the historical background of C, the steps to compile and run a C program in both environments, and provides a simple programming assignment. The conclusion emphasizes the understanding of the compilation process across different operating systems.

Uploaded by

jadhaoshiv3012
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical no.

Aim: - C basics and its compilation(windows and Linux).

Objective: To Study basics of C language and its process of compilation


Theory:-

The C programming language was developed in the early 70’s as a system implementation
language for the Unix operating system. Dennis Ritchie at Bell Labs, USA, originally
developed it. The language was named c because it was successor to a language ‘B’ which
was developed by Ken Thompson in 1969-70, which was derived from Martin Richards
BCPL (Basic Combined Programming Language).

Steps of Compilation of C Program (Windows).


Step 1. Go to command prompt and enter the directory c:\tc\bin>
Step 2.Type and save the program with <filename>.c by invoking editor with the
command TC.
Step 3. Compile with Alt +C compiles menu or Ctrl+F9 key. If there are errors remove it and
recompile the program.
Step 4. Run with Alt + R or Alt + F5 key and note the result.

How to Compile and Run C/C++ program on Ubuntu

Ubuntu is one of the most popular operating system for programming because there
are lot of great open source applications, tools, compilers, debuggers, IDEs are available free
of cost. Some of them are - GCC - The greatest compiler for C language (from FSF (‘Free
Software Foundation’ by Stallman); Linux Torwalds used GCC while developing Linux
Kernel), Eclipse IDE (The most popular ‘Integrated Development Environment’ for Java
programmers), Netbeans, KDevelop, Codelite etc.

C/C++ language is a high level programming language (although the term high and
low is used in relative sense e.g C is a high level language as compared to Assembly but if we
compare it with java then C is a low level programming language; the term high or low
basically describes the closeness with hardware). Most of the operating systems has been
written in C language. This post has been written for beginners who just started learning
C/C++ or the programmers who have migrated from Windows to Ubuntu (although the
commands are almost same for all Linux based operating system).

Step 1. Write and save the program


Open 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>

void main()
{
printf("Hello! This is my first C program with Ubuntu 11.10\
n"); /* Do something more if you want */
}

Step 2. Compile the program


GCC (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 your program then the compiler will successfully
generate an executable file, otherwise fix the problem in your code.

Step 3. Execute the program


To execute the program, you need to run -

./hello1

Conclusion: Thus we have studied the process of compilation of c program(windows and


linux).

Assignment: Create a simple c program using printf () and scanf () functions to input data
from user and to display the same data which is entered.

You might also like