C Programming Lecture Series

Slides:



Advertisements
Similar presentations
An Introduction to Programming By :- Vishal Hirani B.Tech II year (CSE)
Advertisements

Introduction to C Programming CE Lecture 1 Introduction to C.
Unix Continuum of Tools Do something once: use the command line Do something many times: –Use an alias –Use a shell script Do something that is complex.
1 Basics of Linux On linux machine: Login at your home directory Open a “shell” or “terminal” or “xterm” workspace (4) On windows machine Intall linux.
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
CSE : Programming in C Instructor: Lei Wang Office: Dreese Lab 474 Office Hour: Friday.
C PROGRAMMING LECTURE 17 th August IIT Kanpur C Course, Programming club, Fall by Deepak Majeti M-Tech CSE
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
1 CS 240 Programming in C and UNIX Lecturer: Bob Wilson Office: S Phone:
Computational physics PY2050 Course Details:
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Unix Basics Chapter 4.
2INC0 Operating Systems Introduction to Linux
CSE 2541 – Advanced C Programming Instructor: Yang Zhang
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction Unix-like system is everywhere Linux Android for smartphones Google Chrome OS for Chromebook Web.
1 N305 C Programming. 2 Objectives for the Lab ä Learn problem solving strategies ä Achieve intermediate knowledge of C Programming Language ä Gain experience.
LINUX Tuesday, 5 July :00 pm. Remote Login l Use Secure Shell (ssh) l Machine name/IP address E.g. ssh hydra.sma.nus.edu.sg Or ssh
Creating your first C++ program
Programming With C.
PROGRAMMING PROJECT POLICIES AND UNIX INTRO Sal LaMarca CSCI 1302, Fall 2009.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
CSE 2541 – Advanced C Programming. Course info Prereq – CSE 2221 or CSE 222 Co-req – CSE 2231 Website
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
ENEE150 – 0202 ANDREW GOFFIN Introduction to ENEE150.
1 Programming in C Hello World! Soon I will control the world! Soon I will control the world!
Next Unix Topics Tuesday, 2/11 & 18/2014. Change Password (by 2/14/14) ssh to account on – faclinux.cse.ohio-state.edu – stdlinux.cse.ohio-state.edu passwd.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
City Cluster Quickstart Lien-Chi Lai, COLA Lab, Department of Mathematics, NTU 2010/05/11.
Introduction to Programming Using C An Introduction to Operating Systems.
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? – Quick introduction Documentation – Where to get it, how to use it Text Editors – Know.
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
C Programming Lecture 3 : C Introduction 1 Lecture notes : courtesy of Woo Kyun and Chang Byung-Mo.
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
Tutorial Six Linux Basics CompSci Semester Two 2016.
Introduction to C Topics Compilation Using the gcc Compiler
Precept I : Lab Environment, Unix, Bash, Emacs
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Class Projects and Environment
SEEM3460 Tutorial Unix Introduction.
UMBC CMSC 104 – Section 01, Fall 2016
CS1010: Intro Workshop.
Development Environment Basics
Chapter 11 Command-Line Master Class
Prepared by: Eng. Maryam Adel Abdel-Hady
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Introduction to C Topics Compilation Using the gcc Compiler
Introduction to C Topics Compilation Using the gcc Compiler
INTRODUCTION TO UNIX: The Shell Command Interface
Computer Systems and Networks
Computer Science 210 Computer Organization
SEEM3460 Tutorial Unix Introduction Xinshi Lin & Zihao Fu
ברוכים הבאים למת"ם מבוא לתכנות מערכות
Govt. Polytechnic,Dhangar
Introduction to C Topics Compilation Using the gcc Compiler
Creating your first C program
CS 240 Programming in C Lecturer: Ramin Dehghanpoor Office: S-3-134
Your first C and C++ programs
Introduction to C Topics Compilation Using the gcc Compiler
CSE 303 Concepts and Tools for Software Development
Video Notes.
Preparation for Assignment 2
Introduction to C Topics Compilation Using the gcc Compiler
January 26th, 2004 Class Meeting 2
Presentation transcript:

C Programming Lecture Series 16th August IIT Kanpur C Course, Programming club, Fall 2008

C Course, Programming club, Fall 2008 About ‘the’ Course An assignment based course More emphasis on problem solving Instructors: Deepak Majeti. mdeepak@ Nitin Munjal. nitinm@ Rishi Kumar. rishik@ Satendra Kumar Yadav. satendra@ C Course, Programming club, Fall 2008

C Course, Programming club, Fall 2008 Topics to be covered Introduction to Programming in C & Restricted Exposure to Linux - Today Data, Operators, I/O - Tomorrow Conditional Expressions, Control Flow – 23rd Aug. Loops Functions for structure and Recursion Pointer and Arrays Dynamic allocation Structures and Applications, Storage Classes Pre-processor, File Handling, Math library Algorithms: searching, sorting C Course, Programming club, Fall 2008

C Course, Programming club, Fall 2008 Text Kernighan, Ritchie. Second Edition C Course, Programming club, Fall 2008

C Course, Programming club, Fall 2008 Course website Website (slides, important updates) http://students.iitk.ac.in/programmingclub/course/ Discussion page (lecture clash, doubts) http://students.iitk.ac.in/programmingclub/course/discuss.html C Course, Programming club, Fall 2008

C Course, Programming club, Fall 2008 About C GNU : GNU's Not Unix GNU C: gcc is a standard compiler C is non portable Terms: Compiler (human -> machine [once]), Interpreter (instructions -> machine [each time the program is run]) C is a high level language One line in c maps to many lines of assembly code C Course, Programming club, Fall 2008

C Course, Programming club, Fall 2008 My first C program! /* thou shalt begin from somewhere*/ #include <stdio.h> // program prints hello world int main() { printf ("Hello world!\n"); return 0; } C Course, Programming club, Fall 2008

C Course, Programming club, Fall 2008 More.. #include <stdio.h> // program reads and prints the same thing int main() { int number; scanf(“%d”, &number); printf (“%d\n”, number); return 0; } C Course, Programming club, Fall 2008

C Course, Programming club, Fall 2008 1. Programming on Linux Linux command line: GNU-C Use console based editors: vi, emacs, nano Or text based editors: kwrite, gedit, kate IDE Eclipse * http://www.eclipse.org/cdt/downloads.php * = available on windows too. C Course, Programming club, Fall 2008

Linux Familiarization Common shell commands Remember, commands are issued to a shell pwd, ls, dir, mkdir, cd, date, whoami touch, cp, mv, rm, chmod, cat, less, more, tail man Commands are programs (usually in /usr/bin, /bin/) Most commands take options and input ls ls -a ls -l ls -lt ls -ltr Everything is case-sensitive Tab completion, command history C Course, Programming club, Fall 2008

Files, directories and permissions Directory drwxr-xr-x 2 nitinm cse 4096 2008-08-13 22:46 Pictures File -rw-r--r-- 1 nitinm cse 3446 2008-08-14 15:16 test.c Special files (advanced) .a : static library .so : shared object (dynamic) Pipes : fifo / buffered prwx--x--x Device files : /dev/cdrom etc. C Course, Programming club, Fall 2008

Programming on Linux contd… Writing programs Use any editor (graphical, console) Save file as <filename>.c Compiling programs gcc <filename>.c gcc funnysingh.c –o funnysingh Running programs ./a.out ./funnysingh (executable files need to have executable permissions. $chmod +x <executable>) C Course, Programming club, Fall 2008

Compilation is not a single stage Pre process : cpp (C Preprocessor) gcc –E Removes comments, includes #include files Compile : gcc –c (GNU compiler) main step, compilation, change into machine code Link : ld (GNU linker) link executables gcc does all the above steps C Course, Programming club, Fall 2008

C Course, Programming club, Fall 2008 2. C on windows Use a text editor install notepad++ compiler : MinGW how to install and work- http://csjava.occ.cccd.edu/~gilberts/mingw/ IDE Eclipse * Microsoft Visual C++ Express Edition 2008 C Course, Programming club, Fall 2008

Or 3. Work on windows, yet use gcc Install SSH Secure Shell or Putty Connect to cc servers: webhome.cc.iitk.ac.in or linserv.cc.iitk.ac.in etc. Want to see GUI too? Install Xming And then, enable X11 tunnelling C Course, Programming club, Fall 2008

C Course, Programming club, Fall 2008 Why doesn’t my windows binary run on linux? File format: exe and elf man elf In linux, program does system calls. Libraries are different C Course, Programming club, Fall 2008

Good programming practices Indentation #include <stdio.h> int main() { printf("Hello World!\n"); return 0; } #include <stdio.h> int main() { printf("Hello World!\n"); return 0; } C Course, Programming club, Fall 2008

Good programming practices contd.. Variables names Not too short, not too long Always start variable names with small letters On work break Capitalize: myVariable, OR Separate: my_variable C Course, Programming club, Fall 2008

Good programming practices contd... Put comments #include <stdio.h> int main() { /* this program adds two numbers */ int a = 4; //first number int b = 5; //second number int res = 0; //result res = a + b; } C Course, Programming club, Fall 2008

Good programming practices Your code may be used by somebody else The code may be long Should be easy to understand for you and for others Saves lot of errors and makes debugging easier Speeds up program development C Course, Programming club, Fall 2008