CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions OneStopTesting.com - Testing EBooks, Tutorials, Articles, Jobs, Training Institutes etc.
OneStopGate.com - Gate EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopMBA.com - MBA EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopIAS.com - IAS EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopSAP.com - SAP EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopGRE.com - of GRE EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.

Sponsored Links

Interview Questions
Our Services

INTERVIEW QUESTIONS C C BASICS DETAILS
Question :

Can you write a c program without using main function?

Posted by: mohammed nawaz on 12/19/2013

Contact mohammed nawaz Contact mohammed nawaz

Category C Basics Interview Questions
Rating (4.0) By 69 users
Added on 12/19/2013
Views 745
Rate it!


Answers:

Source: CoolInterview.com

we can write the programme without main but it can't run becuase linking is from main().
Source: CoolInterview.com



Posted by: Ameen

Contact Ameen Contact Ameen

Source: CoolInterview.com

yes,we can write c program without using main.
Source: CoolInterview.com



Posted by: c.karuppusamy

Contact c.karuppusamy Contact c.karuppusamy

Source: CoolInterview.com

WE CAN WRITE THE PROGRAM WITHOUT MAIN.BUT,IT WILL NOT RUN.BECAUSE,THE COMPILER PERFORMS THE TASK AFTER SEEING THE MAIN FUNCTION ONLY.OTHERWISE,IT SHOWS ERROR.
Source: CoolInterview.com



Posted by: k.sangeetha

Contact k.sangeetha Contact k.sangeetha

Source: CoolInterview.com

yes, we can write a c program without using main function. but it'll not be executed as the execution starts from the main function only.
Source: CoolInterview.com



Posted by: rashmi

Contact rashmi Contact rashmi

Source: CoolInterview.com

basically,i thought not to post uo solution here but i have seen the same query in many web sites and no proper solution is found
so IM posting here the solution for this tragedic question
1)its true,we can't write a C program without main function
2)IN THIS WORLD NOTHING IS IMPOSSIBLE HEHEHEHE.........
solution:
#include<stdio.h>

#define decode(s,t,u,m,p,e,d) m##s##u##t
#define begin decode(a,n,i,m,a,t,e)

int begin()
{
printf(? hello ?);
}
i listened people who said program will not get executed,DAMN stop such things.if you don't know plz shut your mouths and don't mislead readres plzzzzzzz
the above code works perfectly and if any1 need the explanation for that plz refer www.gohacking.com and in the right most side (below) see C SOURCE CODES coloumn and then read it there clearly.even after that if you have any doubts feel free to contact me at mani.konakandla@yahoo.com
Source: CoolInterview.com



Posted by: venkat

Contact venkat Contact venkat

Source: CoolInterview.com

otherwise try this one...

_start()
{
_exit(function_name())
}
void funtion_name()
{
printf("Without main
");
}


and compile this code like this..
$cc -nostartfile source_file.c
Source: CoolInterview.com



Posted by: Rao Sahab

Contact Rao Sahab Contact Rao Sahab

Source: CoolInterview.com

yeah ofcourse we can write a c prog without using main().,. but it leads to error in it's execution stage
Source: CoolInterview.com



Posted by: lol

Contact lol Contact lol

Source: CoolInterview.com

a program cannot be executed witout a main()function.Since te compiler starts compiling te program after te main()
Source: CoolInterview.com



Posted by: sukanya

Contact sukanya Contact sukanya

Source: CoolInterview.com

we can write the code without main() function. The code will gets compiled and during compilation it won't show any error but while executing it show an error saying LINKER ERROR.
Source: CoolInterview.com



Posted by: deepak

Contact deepak Contact deepak

Source: CoolInterview.com

Yes we can write a C Program without writing main()

see this

#include<stdio.h>
#include<conio.h>
#pragma start show()

void show()
{
printf("Hello");
}

Source: CoolInterview.com



Posted by: Swesh Mishra

Contact Swesh Mishra Contact Swesh Mishra

Source: CoolInterview.com

yes you can write a program without main but in short just like this

#include<stdio.h>
#include<conio.h>
{
printf("stupids we can do anything");
}
Source: CoolInterview.com



Posted by: sanjana

Contact sanjana Contact sanjana

Source: CoolInterview.com

yes we can write c prog without using main() but it will not run because the prog execution always begins with the main() function.
so it will give an error.
Source: CoolInterview.com



Posted by: abhinav kumar singh

Contact abhinav kumar singh Contact abhinav kumar singh

Source: CoolInterview.com

The compilation process always starts from the first line of your source code and the compiler checks only syntax, if you don't have a main() not at all a problem. But if you want to execute that you need main(). Check how we are going to create a header file are we going to place a main() in a header file.
Source: CoolInterview.com



Posted by: venkatesh

Contact venkatesh Contact venkatesh

Source: CoolInterview.com

No we conn't write c program with out using main().Because it shows error in its run time.
Source: CoolInterview.com



Posted by: Latthi.k

Contact Latthi.k Contact Latthi.k

Source: CoolInterview.com

#include<stdio.h>

#define decode(s,t,u,m,p,e,d) m##s##u##t
#define begin decode(a,n,i,m,a,t,e)

int begin()
{
printf(? without main ?);
}
Source: CoolInterview.com



Posted by: naresh

Contact naresh Contact naresh

Source: CoolInterview.com

main is not compulsory, every C program needs an entry point so it can be main, pain, slain or anything else, in embedded systems the low level startup code jumps to main, u can change it to something else, similar in visual studio or turbo C u need to find out a compile directive to change the default jump to main.
and to correct the above answers it is not an runtime error, it is linking error
Source: CoolInterview.com



Posted by: shrads

Contact shrads Contact shrads

Source: CoolInterview.com

yes, we can write c program without main function ,but this program can't execute without main function.
some errors can you found.
so, boy you write with main....,
Source: CoolInterview.com



Posted by: ritu raj

Contact ritu raj Contact ritu raj

Source: CoolInterview.com

Ya it is not possible to execute a C program without main though u can compile it successfully.
Compiler will check for only syntactical errors.
It never bother about whether the main is present in the program or not.
It is possible to execute a program without main in java but not in C.
Source: CoolInterview.com



Posted by: Ravinder Reddy

Contact Ravinder Reddy Contact Ravinder Reddy

Source: CoolInterview.com

we can write a c program without main function using PreProcessors.

#define k 5
#define n 12
#if (n>k) printf("n is big campare to k ");
#elif printf("n is small campare to k");
#endif
Source: CoolInterview.com



Posted by: Bharat kumar .G

Contact Bharat kumar .G Contact Bharat kumar .G

Source: CoolInterview.com

Hi Friends..

See the above code which is posted by Venkat..That code will works but at there also internally void()methods called by the processor.
Source: CoolInterview.com



Posted by: Kiran Kuma Kala

Contact Kiran Kuma Kala Contact Kiran Kuma Kala

Source: CoolInterview.com

yes, we can write but in the linking time it will throw error
undefined reference to main
ld returned one exit status
Source: CoolInterview.com



Posted by: iranna

Contact iranna Contact iranna

Source: CoolInterview.com

according to me,program can be written without main() but it will not run because before runing the program compiler will not compile the program without main().
Source: CoolInterview.com



Posted by: vikash chesi

Contact vikash chesi Contact vikash chesi

If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification Enter the above shown code: *
Inform me about updated answers to this question

Related Questions
View Answer
Tell me answer for this statement
printf("printf("aim")");
- C Basics Interview Questions & Answers"> View Answer
Difference between :- 1) C and C++
2) main() in c and main() in c++ ?
View Answer
What is :- Asembler , compiler , Preprocessor , laxical analysis , parsing ?
View Answer
How can we use data connectivity in 'c' language?
View Answer
Write a program for result management system of a college ?
View Answer
Is it possible to print graphics output in C?
View Answer
How can C programs run without header files?
View Answer
What is c graphics?
View Answer
write a program for printing when i press a key next to the letter in the alphabetical order can be printed
View Answer
how to create relation calculator program using c language
View Answer
how to create love flames program using c language
View Answer
Can anyone please tell me about a website from which I could install Turbo C (compiler) for free??
View Answer
What is the use of semicolon at the end of every statement?
View Answer
What are the packages in c?
View Answer
What is object file? How can you access object file?
View Answer
Is there anything you can do in C++ that you cannot do in C ?
View Answer
What is an abstract base class?
View Answer
What is the difference between compile time error and run time error?
View Answer
What is the difference between #include <file> and #include �file�
View Answer
When we access the integer and the character variables without declaring them in program?and Why?
View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

View ALL C Basics Interview Questions & Answers



User Options
India News Network

Latest 20 Questions
What is Profession Tax in Andhra Pradesh?
What is Profession Tax in West Bengal?
What is Profession Tax in Karnataka?
What is Profession Tax in Delhi?
What is Profession Tax in Maharashtra?
Who is appellate authority in Maharastra, under Profession Tax Act?
Can parents/Guardians of physically handicapped children get exemption from Profession Tax?
Whether it is necessary to submit medical certificate for exemption from Profession Tax?
Who can get exemption from Profession Tax?
If there is no previous year in the profession then what will be the rate of Profession Tax?
On what basis Profession Tax shall be calculated?
What are the rates of tax under Profession Tax Act?
Who is assessed under Profession Tax Act?
What type of incentives will be available after making such lump sum payment fpr Enrollment Certificate for Professional Tax (PT)?
What are the advantages of making lump sum payment of Professional Tax (PT)?
Is there any facility of making lump sum payment of Profession Tax?
Are medical practitioners, commission agents and partners of firms eligible for enrollment certificate for Professional Tax (PT)?
Are self employed persons eligible to get enrollment certificate of Professional Tax (PT)?
What is the rate of interest for late payment of Professional Tax (PT)?
Where and how much Profession Tax (PT) is to be paid?



Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |




Copyright ©2003-2016 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions



Cache = 0.014648 Seconds