Skip to content

This repository contains all the code in the book The C Programming Language by Kernhingan & Ritchie

Notifications You must be signed in to change notification settings

varunjha089/The-C-Programming-Language

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 

Repository files navigation

The C Programming Language

The C Programming Language by Kernighan and Ritchie is awesome book to start C programming.

Table of Content

Chapter Title Link
Chapter-01 A tutorial Introduction Link
Chapter-02 Types, Operators and Expression Link
Chapter-03 Control Flow Link
Chapter-04 Function and Program Structure Link
Chapter-05 Pointers and Array Link
Chapter-06 Structures Link
Chapter-07 Input and Output Link
Chapter-08 The UNIX System Interface Link
Appendix A. Reference Manual Link
Appendix B. Standard Library Link
Appendix C. Symmary of Change Link

Installing the required tools

Install vcpkg on Windows, Linux, and macOS has a very descriptive for evely flavour of operaing system. But for linux follow the command

ubuntu@ip:~$ sudo apt-get update

ubuntu@ip:~$ sudo apt-get install build-essential tar curl zip unzip

ubuntu@ip:~$ git clone https://github.com/microsoft/vcpkg

ubuntu@ip:~$ cd vcpkg

ubuntu@ip:~$ ./bootstrap-vcpkg.sh

Running a C file using command line

If the file name is HelloWorld.c the the command is :-

ubuntu@ip:~$ cc HelloWorld.c && ./a.out

Commenting in C Programme

#include <stdio.h>
/* Some comments*/
int main(){
    printf("");
}

C Data Types

Data Type Description
int int means the variable are listed as Integer
float fload means the variable are listed as Floating Point value
char char means the variable are listed as character -- a single byte
short short means the variable are listed as short integer
long long means the variable are listed as long integer
double double means the variable are listed as double-precision floating point

The size of these objects are machine dependent, but in general 16-bit ints lies between -32768 and +32767. A float number is typically a 32-bit quantity, with at least six signigicant digits and magintude between 10^-38 and 10^38.

Precision in C Programme

Precision Description
%d print as decimal integer
%6d print as decimal integer, at least 6 character wide
%f print as floating point
%6f print as floating point, at least 6 character wide
%.2 print as floating point, 2 character after decimal point
%6.2 print as floating point, at least 6 wide and 2 after decimal point

Symbolic Constant

Syntax :-

#define name replacement text

Example :-

#include <stdio.h>

#define LOWER 5

int main(){
    printf("%d\n", LOWER);
}

Error Received While Playing in C Programme

Error Cause of Error
error: expected ‘;’ before ‘}’ token Semi-Colon is missing somewhere in programme.
error: expected ‘)’ before ‘;’ token Parentheses is missing. It can happen when opening parentheses is missing also.

About

This repository contains all the code in the book The C Programming Language by Kernhingan & Ritchie

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages