0% found this document useful (0 votes)
53 views

CS1000 Basic Programming: Computing Lab - II

This document provides an introduction to the C programming language. It discusses the history and origins of C, noting that it was invented by Dennis Ritchie in 1972. It explains that C is a general purpose, efficient, and reliable language that forms the basis for many operating systems and embedded systems. The document also covers basic C programming concepts like data types, functions, comments, and input/output. It provides examples of simple C programs and discusses how to compile and run C code on Windows and Linux systems.

Uploaded by

Partho Biswas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

CS1000 Basic Programming: Computing Lab - II

This document provides an introduction to the C programming language. It discusses the history and origins of C, noting that it was invented by Dennis Ritchie in 1972. It explains that C is a general purpose, efficient, and reliable language that forms the basis for many operating systems and embedded systems. The document also covers basic C programming concepts like data types, functions, comments, and input/output. It provides examples of simple C programs and discusses how to compile and run C code on Windows and Linux systems.

Uploaded by

Partho Biswas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

CS1000

Basic Programming

Computing Lab -II

Dr. Arun Kumar


Dept. of CSE, NIT Rourkela
Odisha-769008
C Programming Language

Programming
Language

Instructions

Program

Programmer Computer
Why C? History and why you should
study C?
— Inventor – Dennis Ritchie in 1972 (Book : The C
Programming Language - Ritchie & kernighan)
— Why we call is C? Why now D, E, F, G etc. ?
— It’s the successor of B Language and B language is
the successor of BCPL (Basic Combined
Programming Language).
BCPL

C
Why C? History and why you should
study C?
— A basic foundation for learning programming
language elements: easy and simple to learn
— Efficient and reliable
— C is a general purpose programming language:
— Embedded System Programs are written in C
— Microwave Oven
— Washing machines
— Digital Cameras
— NASA MARS ROVER
Why C? History and why you should
study C?
— Major parts of popular OS like windows, Linux, Unix
are written in C.
— C provides several language elements that makes
interaction with hardware.
— Several Gaming programs are also developed in C.
— If you know C then learning C++, Java and C# is very
easy.
Programming Languages

Low Level High Level

Machine Level Assembly Language

01010010001 MOV A,5


01110010101 MOV B,2
00101100001 ADD A,B
More About High Level Languages
— The languages are designed keeping in mind features
of portability.

— The languages are machine independent.


— Programs are portable

— Easy to write and understand.

— The programmer pays whole attention to logic of the


program.
Translators
— For translating high level and low level language to
machine language: German to Hindi
— Assembler: Assembly Level Machine Level
— Interpreter:
— High Level Machine Level
— Interpreter searches the error statement by statement
— Compiler:
— High Level Machine Level
— Compiler searches all errors in the code and lists them
Some High Level Languages
— BASIC
— FORTRAN
— PASCAL
— COBOL
—C
— C++
— Java
Object file
.obj or .o
Memory .c

.exe
First C Program
/* Comments within code*/ To include
information about
#include<stdio.h> standard
main() Function main input/output

{
printf(“Hello World\n”); Body of Function

}
Second C Program
/* This program accepts an integer as
input and outputs the same integer*/
#include <stdio.h>
main ()
{
int n;
scanf("%d",&n);
printf("%d\n",n);
}
Third C Program
/* This program takes an integer n as
input and outputs the square n2 of n.*/
#include <stdio.h>
main ()
{
int n;
scanf("%d",&n);
printf("%d\n",n*n);
}
How to run a program in Windows
— Toolset- Turbo C, GNU C Compiler, MS Visual C,

— How to Compile and Run C program in Windows?


—Turbo C
https://www.youtube.com/watch?v=CRnIQhYTsXM
Writing the code

— How to Compile and Run C program Using GCC on


Ubuntu?
https://www.youtube.com/watch?v=oLjN6jAg-sYcc
hello.c
Compiling C Program - Linux
— Writing the code
— vi hello.c
— insert data (i)
— save changes (Keys: esc:wq)
— cc hello.c
— The compiler generates an executable
— a.out
— Type ./a.out
— Output
Hello World
Compiling C Program - Linux
— Create a directory: mkdir progs
— Go to a new directory: cd progs/
— Go to the parent directory: cd ../
— List all files in a directory: ls -lF
— View a file: cat filename
— Copy a file to another: cp file1.c file2.c
— Copy a file to a directory: cp file1.c progs/file3.c
— Move a file to another: mv file1.c file2.c
— Move a file to a directory: mv file1.c progs/file3.c
— Delete a file: rm filename
References
— Kanetkar, Yashavant, “Let Us C”

— “ANSI C” by Balaguruswamy

— S. K. Srivastava and Deepali Srivastava, “C In Depth”.

— Kernighan and Ritchie, “The C Programming


Language”
Thank You

You might also like