SlideShare ist ein Scribd-Unternehmen logo
1 von 5
C - Program Structure
C Hello World Example
A C program basically consists of the following parts:
Preprocessor Commands
Functions
Variables
Statements & Expressions
Comments
#include <stdio.h>
int main()
{
/* my first program in C */
printf("Hello, World! n");
return 0;
}
$ gcc hello.c
$ ./a.out
Hello, World!
Let us look various parts of the above program:
The first line of the program #include <stdio.h> is a preprocessor
command, which tells a C compiler to include stdio.h file before going
to actual compilation.
The next line int main() is the main function where program execution
begins.
The next line /*...*/ will be ignored by the compiler and it has been put
to add additional comments in the program. So such lines are called
comments in the program.
The next line printf(...) is another function available in C which causes
the message "Hello, World!" to be displayed on the screen.
The next line return 0; terminates main()function and returns the
value 0.
Lets look at how to save the source code in a file, and how to compile
and run it. Following are the simple steps:
Open a text editor and add the above-mentioned code.
2. Save the file as hello.c
3. Open a command prompt and go to the directory where you saved
the file.
4. Type gcc hello.c and press enter to compile your code.
5. If there are no errors in your code the command prompt will take
you to the next line and would generate a.out executable file.
6. Now, type a.out to execute your program.
7. You will be able to see "Hello World" printed on the screen

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04
hassaanciit
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
Amit Kapoor
 

Was ist angesagt? (20)

C Programming Language Part 11
C Programming Language Part 11C Programming Language Part 11
C Programming Language Part 11
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
Function (rule in programming)
Function (rule in programming)Function (rule in programming)
Function (rule in programming)
 
Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04
 
6. function
6. function6. function
6. function
 
C programming
C programmingC programming
C programming
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]
 
Input And Output
 Input And Output Input And Output
Input And Output
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
C programming pointer
C  programming pointerC  programming pointer
C programming pointer
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string library
 
function in c
function in cfunction in c
function in c
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
 
Compiler Design Lab File
Compiler Design Lab FileCompiler Design Lab File
Compiler Design Lab File
 
C structure
C structureC structure
C structure
 
C Programming
C ProgrammingC Programming
C Programming
 

Andere mochten auch

Programming language
Programming languageProgramming language
Programming language
Ayesha Waheed
 
BAIT1003 Chapter 7
BAIT1003 Chapter 7BAIT1003 Chapter 7
BAIT1003 Chapter 7
limsh
 
Generations of Programming Languages
Generations of Programming LanguagesGenerations of Programming Languages
Generations of Programming Languages
Tarun Sharma
 

Andere mochten auch (20)

Basic construction of c
Basic construction of cBasic construction of c
Basic construction of c
 
C Programming Language Step by Step Part 1
C Programming Language Step by Step Part 1C Programming Language Step by Step Part 1
C Programming Language Step by Step Part 1
 
My first program in c, hello world !
My first program in c, hello world !My first program in c, hello world !
My first program in c, hello world !
 
Programming language
Programming languageProgramming language
Programming language
 
BAIT1003 Chapter 7
BAIT1003 Chapter 7BAIT1003 Chapter 7
BAIT1003 Chapter 7
 
Computer Programming_Unit 1
Computer Programming_Unit 1Computer Programming_Unit 1
Computer Programming_Unit 1
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manual
 
Embedded c program and programming structure for beginners
Embedded c program and programming structure for beginnersEmbedded c program and programming structure for beginners
Embedded c program and programming structure for beginners
 
Generations of Programming Languages
Generations of Programming LanguagesGenerations of Programming Languages
Generations of Programming Languages
 
Generations of computer
Generations of computerGenerations of computer
Generations of computer
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
 
The different kind of programming language
The  different kind of programming languageThe  different kind of programming language
The different kind of programming language
 
Deployable Disaster Device
Deployable Disaster DeviceDeployable Disaster Device
Deployable Disaster Device
 
дії населення в разі виявлення запаху газу
дії населення в разі виявлення запаху газудії населення в разі виявлення запаху газу
дії населення в разі виявлення запаху газу
 
Work.Life.Leader Manifesto
Work.Life.Leader ManifestoWork.Life.Leader Manifesto
Work.Life.Leader Manifesto
 
David Bellatalla, intervista
David Bellatalla, intervistaDavid Bellatalla, intervista
David Bellatalla, intervista
 
я — громадянин україни
я — громадянин україния — громадянин україни
я — громадянин україни
 
Smoking kills........by majid rabbani
Smoking kills........by majid rabbaniSmoking kills........by majid rabbani
Smoking kills........by majid rabbani
 
Why Invest for Retirement?
Why Invest for Retirement?Why Invest for Retirement?
Why Invest for Retirement?
 
Actividad n 01 mecanica1
Actividad n 01 mecanica1Actividad n 01 mecanica1
Actividad n 01 mecanica1
 

Ähnlich wie C Programming Language Step by Step Part 2

C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
AashutoshChhedavi
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ Program
Deepak Singh
 
Introduction to Computer and Programing - Lab2
Introduction to Computer and Programing - Lab2Introduction to Computer and Programing - Lab2
Introduction to Computer and Programing - Lab2
hassaanciit
 

Ähnlich wie C Programming Language Step by Step Part 2 (20)

Basic c programming and explanation PPT1
Basic c programming and explanation PPT1Basic c programming and explanation PPT1
Basic c programming and explanation PPT1
 
Program structure of c
Program structure of cProgram structure of c
Program structure of c
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5
 
[ITP - Lecture 03] Introduction to C/C++
[ITP - Lecture 03] Introduction to C/C++[ITP - Lecture 03] Introduction to C/C++
[ITP - Lecture 03] Introduction to C/C++
 
Stucture of c program
Stucture of c programStucture of c program
Stucture of c program
 
OVERVIEW OF ‘C’ PROGRAM
OVERVIEW OF ‘C’ PROGRAMOVERVIEW OF ‘C’ PROGRAM
OVERVIEW OF ‘C’ PROGRAM
 
basic program
basic programbasic program
basic program
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptx
 
CC 3 - Module 2.pdf
CC 3 - Module 2.pdfCC 3 - Module 2.pdf
CC 3 - Module 2.pdf
 
Intro to c++
Intro to c++Intro to c++
Intro to c++
 
Chapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ ProgramChapter 2 - Structure of C++ Program
Chapter 2 - Structure of C++ Program
 
Introduction to Computer and Programing - Lab2
Introduction to Computer and Programing - Lab2Introduction to Computer and Programing - Lab2
Introduction to Computer and Programing - Lab2
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
Introduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to itIntroduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to it
 
Fp201 unit2 1
Fp201 unit2 1Fp201 unit2 1
Fp201 unit2 1
 
CHAPTER 3
CHAPTER 3CHAPTER 3
CHAPTER 3
 
Chapter 3(1)
Chapter 3(1)Chapter 3(1)
Chapter 3(1)
 
C++ Chapter 3
C++ Chapter 3C++ Chapter 3
C++ Chapter 3
 
#Include
#Include#Include
#Include
 

Mehr von Rumman Ansari

Mehr von Rumman Ansari (20)

Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
C programming exercises and solutions
C programming exercises and solutions C programming exercises and solutions
C programming exercises and solutions
 
Java Tutorial best website
Java Tutorial best websiteJava Tutorial best website
Java Tutorial best website
 
Java Questions and Answers
Java Questions and AnswersJava Questions and Answers
Java Questions and Answers
 
servlet programming
servlet programmingservlet programming
servlet programming
 
C program to write c program without using main function
C program to write c program without using main functionC program to write c program without using main function
C program to write c program without using main function
 
Steps for c program execution
Steps for c program executionSteps for c program execution
Steps for c program execution
 
Pointer in c program
Pointer in c programPointer in c program
Pointer in c program
 
How c program execute in c program
How c program execute in c program How c program execute in c program
How c program execute in c program
 
What is token c programming
What is token c programmingWhat is token c programming
What is token c programming
 
What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
 
What is keyword in c programming
What is keyword in c programmingWhat is keyword in c programming
What is keyword in c programming
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
 
C Programming Language Part 5
C Programming Language Part 5C Programming Language Part 5
C Programming Language Part 5
 
C Programming Language Part 4
C Programming Language Part 4C Programming Language Part 4
C Programming Language Part 4
 
C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3C Programming Language Step by Step Part 3
C Programming Language Step by Step Part 3
 
C Programming
C ProgrammingC Programming
C Programming
 
Tail recursion
Tail recursionTail recursion
Tail recursion
 
Tail Recursion in data structure
Tail Recursion in data structureTail Recursion in data structure
Tail Recursion in data structure
 
Spyware manual
Spyware  manualSpyware  manual
Spyware manual
 

Kürzlich hochgeladen

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 

Kürzlich hochgeladen (20)

Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 

C Programming Language Step by Step Part 2

  • 1. C - Program Structure
  • 2. C Hello World Example A C program basically consists of the following parts: Preprocessor Commands Functions Variables Statements & Expressions Comments
  • 3. #include <stdio.h> int main() { /* my first program in C */ printf("Hello, World! n"); return 0; } $ gcc hello.c $ ./a.out Hello, World!
  • 4. Let us look various parts of the above program: The first line of the program #include <stdio.h> is a preprocessor command, which tells a C compiler to include stdio.h file before going to actual compilation. The next line int main() is the main function where program execution begins. The next line /*...*/ will be ignored by the compiler and it has been put to add additional comments in the program. So such lines are called comments in the program. The next line printf(...) is another function available in C which causes the message "Hello, World!" to be displayed on the screen. The next line return 0; terminates main()function and returns the value 0.
  • 5. Lets look at how to save the source code in a file, and how to compile and run it. Following are the simple steps: Open a text editor and add the above-mentioned code. 2. Save the file as hello.c 3. Open a command prompt and go to the directory where you saved the file. 4. Type gcc hello.c and press enter to compile your code. 5. If there are no errors in your code the command prompt will take you to the next line and would generate a.out executable file. 6. Now, type a.out to execute your program. 7. You will be able to see "Hello World" printed on the screen