SlideShare a Scribd company logo
C Program to Write
C Program Without
using Main Function
in 3 ways
Run C Program Without Main Function
Conceptually C Program is meaningless without main Function . Every
Program Must have Main Function.
Main Function :
a] It is Entry Point of Every C Program.
b] All Predefined and User-defined Functions are called directly or
indirectly through the main.
c] So C Program Must have Main Function.
But I have decided not to write main and want to run C Program , How ?
We have 3 approaches of Writing C Program without using main().
1
2
3
4
5
6
7
#include<stdio.h>
#define begin main
int begin() {
printf("Hello");
return (0);
}
Way 1 : Using #define Preprocessor Directive
Way 1 : Using #define Preprocessor Directive
What Preprocessor is doing Here ?
• Save C Program using Extension .C
• Before Program is given to compiler program is processed by
Preprocessor .
• begin main
• Source Program is scanned from Left to Right and from Top
to Bottom and “begin” is replaced by “main”
• So Programmer feels that “He has written Code Without
using Main , but internally begin is already converted into
main”
1
2
3
4
5
6
#include<stdio.h>
#define begin m##a##i##n
void begin() {
printf("Hello");
}
Way 2 : Using #define Token Merging Operator
Explain ?
• The ‘##‘ operator is called the token pasting or token merging operator.
• That is we can merge two or more characters with it.
1
2
3
4
5
6
#include<stdio.h>
#define begin m##a##i##n
void begin() {
printf("Hello");
}
Way 3 : Using Argumented Macro

More Related Content

What's hot (13)

PDF
Design of Efficycle- Human Powered Light Weight Hybrid Tricycle with Inbuilt ...
ABHAY TIWARI
 
PPTX
automatic side stand retriever system
Akhil Chowdary
 
PPTX
JOSHUA SEMINAR FINAL (ADAS) (4) (2).pptx
FREDYJoy2
 
PPTX
Daa unit 1
Abhimanyu Mishra
 
PPTX
EMBEDDED IN AUTOMOBILES
Dileep Mittapalli
 
PPTX
Building ADAS system from scratch
Yury Gorbachev
 
PPT
REVIEW ON ADAPTIVE CRUISE CONTROL IN AUTOMOBILES
vishnusankar369
 
PDF
793 c xq
stmsith5012
 
PDF
Abs brake09
Vishwanandan Kumar Singh
 
PPT
Basic of automobile.ppt
Gurinder Singh
 
PPT
Kalman filter
Raghava Raghu
 
PPTX
Vehicle Tracking and Locking System
Kumar Prateek
 
PDF
Basic car terminologies
HEMANTRAUT
 
Design of Efficycle- Human Powered Light Weight Hybrid Tricycle with Inbuilt ...
ABHAY TIWARI
 
automatic side stand retriever system
Akhil Chowdary
 
JOSHUA SEMINAR FINAL (ADAS) (4) (2).pptx
FREDYJoy2
 
Daa unit 1
Abhimanyu Mishra
 
EMBEDDED IN AUTOMOBILES
Dileep Mittapalli
 
Building ADAS system from scratch
Yury Gorbachev
 
REVIEW ON ADAPTIVE CRUISE CONTROL IN AUTOMOBILES
vishnusankar369
 
793 c xq
stmsith5012
 
Basic of automobile.ppt
Gurinder Singh
 
Kalman filter
Raghava Raghu
 
Vehicle Tracking and Locking System
Kumar Prateek
 
Basic car terminologies
HEMANTRAUT
 

Viewers also liked (20)

PPTX
Steps for c program execution
Rumman Ansari
 
PPT
Basics of C programming
avikdhupar
 
PPTX
My first program in c, hello world !
Rumman Ansari
 
PPT
Steps for Developing a 'C' program
Sahithi Naraparaju
 
PPTX
C Programming Language Part 5
Rumman Ansari
 
PPTX
C Programming Language Part 11
Rumman Ansari
 
PPTX
C Programming Language Part 6
Rumman Ansari
 
PPTX
Pointer in c program
Rumman Ansari
 
PPTX
How c program execute in c program
Rumman Ansari
 
PPTX
String
Samsil Arefin
 
PPTX
Chapter 5.3
sotlsoc
 
PPSX
Multidimentional array
Dhiviya Rose
 
PDF
Programming in C
Vineet Kumar Saini
 
DOCX
Properties EM
tejas2019
 
PPT
Infrared spectoscopy
Rawat DA Greatt
 
PPTX
Presentation on function
Abu Zaman
 
PPT
Computational Spectroscopy in G03
Inon Sharony
 
PPTX
How To Start And Keep Conversations Going With Girls
George Hutton
 
PPT
Infrared spectroscopy
Rawat DA Greatt
 
PPT
COMPUTER PROGRAMMING UNIT 1 Lecture 1
Vishal Patil
 
Steps for c program execution
Rumman Ansari
 
Basics of C programming
avikdhupar
 
My first program in c, hello world !
Rumman Ansari
 
Steps for Developing a 'C' program
Sahithi Naraparaju
 
C Programming Language Part 5
Rumman Ansari
 
C Programming Language Part 11
Rumman Ansari
 
C Programming Language Part 6
Rumman Ansari
 
Pointer in c program
Rumman Ansari
 
How c program execute in c program
Rumman Ansari
 
Chapter 5.3
sotlsoc
 
Multidimentional array
Dhiviya Rose
 
Programming in C
Vineet Kumar Saini
 
Properties EM
tejas2019
 
Infrared spectoscopy
Rawat DA Greatt
 
Presentation on function
Abu Zaman
 
Computational Spectroscopy in G03
Inon Sharony
 
How To Start And Keep Conversations Going With Girls
George Hutton
 
Infrared spectroscopy
Rawat DA Greatt
 
COMPUTER PROGRAMMING UNIT 1 Lecture 1
Vishal Patil
 
Ad

Similar to C program to write c program without using main function (20)

PDF
C class basic programming 1 PPT mayanka (1).pdf
mayankamandal
 
PPT
Lec 10
kapil078
 
PDF
C basics programming ppt by Mayanka .pdf
mayankamandal
 
PDF
6 c control statements branching &amp; jumping
MomenMostafa
 
PPTX
Control structure of c
Komal Kotak
 
DOCX
Core programming in c
Rahul Pandit
 
PDF
Cse115 lecture04introtoc programming
Md. Ashikur Rahman
 
DOCX
C language industrial training report
Raushan Pandey
 
PPTX
Programming in C
Nishant Munjal
 
PPTX
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
AbcdR5
 
PPTX
c_pro_introduction.pptx
RohitRaj744272
 
PDF
C programing Tutorial
Mahira Banu
 
PPTX
C PROGRAMMING document for beginners....
reethabar
 
PDF
C certification-questions
Yasser Ibrahim
 
PPTX
Understand more about C
Yi-Hsiu Hsu
 
PPTX
structure of a c program - slideshare.pptx
PoovizhiP1
 
PPTX
C Language ppt create by Anand & Sager.pptx
kumaranand07297
 
PPT
Introduction to C
Janani Satheshkumar
 
C class basic programming 1 PPT mayanka (1).pdf
mayankamandal
 
Lec 10
kapil078
 
C basics programming ppt by Mayanka .pdf
mayankamandal
 
6 c control statements branching &amp; jumping
MomenMostafa
 
Control structure of c
Komal Kotak
 
Core programming in c
Rahul Pandit
 
Cse115 lecture04introtoc programming
Md. Ashikur Rahman
 
C language industrial training report
Raushan Pandey
 
Programming in C
Nishant Munjal
 
C BASICS.pptx FFDJF/,DKFF90DF SDPJKFJ[DSSIFLHDSHF
AbcdR5
 
c_pro_introduction.pptx
RohitRaj744272
 
C programing Tutorial
Mahira Banu
 
C PROGRAMMING document for beginners....
reethabar
 
C certification-questions
Yasser Ibrahim
 
Understand more about C
Yi-Hsiu Hsu
 
structure of a c program - slideshare.pptx
PoovizhiP1
 
C Language ppt create by Anand & Sager.pptx
kumaranand07297
 
Introduction to C
Janani Satheshkumar
 
Ad

More from Rumman Ansari (20)

PDF
Sql tutorial
Rumman Ansari
 
PDF
C programming exercises and solutions
Rumman Ansari
 
PDF
Java Tutorial best website
Rumman Ansari
 
DOCX
Java Questions and Answers
Rumman Ansari
 
DOCX
servlet programming
Rumman Ansari
 
PPTX
What is token c programming
Rumman Ansari
 
PPTX
What is identifier c programming
Rumman Ansari
 
PPTX
What is keyword in c programming
Rumman Ansari
 
PPTX
Type casting in c programming
Rumman Ansari
 
PPTX
C Programming Language Part 9
Rumman Ansari
 
PPTX
C Programming Language Part 8
Rumman Ansari
 
PPTX
C Programming Language Part 7
Rumman Ansari
 
PPTX
C Programming Language Part 4
Rumman Ansari
 
PPTX
C Programming Language Step by Step Part 5
Rumman Ansari
 
PPTX
C Programming Language Step by Step Part 3
Rumman Ansari
 
PPTX
C Programming Language Step by Step Part 2
Rumman Ansari
 
PPTX
C Programming Language Step by Step Part 1
Rumman Ansari
 
PPTX
Basic c programming and explanation PPT1
Rumman Ansari
 
DOCX
C Programming
Rumman Ansari
 
PPTX
Tail recursion
Rumman Ansari
 
Sql tutorial
Rumman Ansari
 
C programming exercises and solutions
Rumman Ansari
 
Java Tutorial best website
Rumman Ansari
 
Java Questions and Answers
Rumman Ansari
 
servlet programming
Rumman Ansari
 
What is token c programming
Rumman Ansari
 
What is identifier c programming
Rumman Ansari
 
What is keyword in c programming
Rumman Ansari
 
Type casting in c programming
Rumman Ansari
 
C Programming Language Part 9
Rumman Ansari
 
C Programming Language Part 8
Rumman Ansari
 
C Programming Language Part 7
Rumman Ansari
 
C Programming Language Part 4
Rumman Ansari
 
C Programming Language Step by Step Part 5
Rumman Ansari
 
C Programming Language Step by Step Part 3
Rumman Ansari
 
C Programming Language Step by Step Part 2
Rumman Ansari
 
C Programming Language Step by Step Part 1
Rumman Ansari
 
Basic c programming and explanation PPT1
Rumman Ansari
 
C Programming
Rumman Ansari
 
Tail recursion
Rumman Ansari
 

Recently uploaded (20)

PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
PDF
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
PDF
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PDF
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Design Thinking basics for Engineers.pdf
CMR University
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
mbse_An_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 

C program to write c program without using main function

  • 1. C Program to Write C Program Without using Main Function in 3 ways
  • 2. Run C Program Without Main Function Conceptually C Program is meaningless without main Function . Every Program Must have Main Function. Main Function : a] It is Entry Point of Every C Program. b] All Predefined and User-defined Functions are called directly or indirectly through the main. c] So C Program Must have Main Function. But I have decided not to write main and want to run C Program , How ? We have 3 approaches of Writing C Program without using main().
  • 3. 1 2 3 4 5 6 7 #include<stdio.h> #define begin main int begin() { printf("Hello"); return (0); } Way 1 : Using #define Preprocessor Directive
  • 4. Way 1 : Using #define Preprocessor Directive What Preprocessor is doing Here ? • Save C Program using Extension .C • Before Program is given to compiler program is processed by Preprocessor . • begin main • Source Program is scanned from Left to Right and from Top to Bottom and “begin” is replaced by “main” • So Programmer feels that “He has written Code Without using Main , but internally begin is already converted into main”
  • 5. 1 2 3 4 5 6 #include<stdio.h> #define begin m##a##i##n void begin() { printf("Hello"); } Way 2 : Using #define Token Merging Operator Explain ? • The ‘##‘ operator is called the token pasting or token merging operator. • That is we can merge two or more characters with it.
  • 6. 1 2 3 4 5 6 #include<stdio.h> #define begin m##a##i##n void begin() { printf("Hello"); } Way 3 : Using Argumented Macro