Find the best tutors and institutes for C Language

Find Best C Language Classes

Please select a Category.

Please select a Locality.

No matching category found.

No matching Locality found.

Outside India?

Search for topics

Some Tricky Questions in C

Sahana D.
16 Feb 0 0

Can you write two functions in which one executes before main function and other executes after the main function?

#pragma startup [priority]
#pragma exit [priority]

Where, priority is optional integer value.
For user priority varies from 64 to 255
For c libraries priority varies from 0 to 63
Default priority is 100.

pragma startup always execute the function before the main function pragma exit always execute the function after the main function. Function declaration of must be before startup and exit pragma directives and function must not take any argument and return void. If more than one startup directive then priority decides which one will execute first.

Lower value: higher priority i.e. functions will execute first. If more than one exit directive then priority decides which one will execute first.

Higher value: higher priority i.e. functions will execute first. 



void india();
void usa() ;
#pragma startup india 105
#pragma startup usa
#pragma exit usa
#pragma exit india 105

int main(){
printf("\nI am in main");
return 0;

void india(){
printf("\nI am in india");

void usa(){
printf("\nI am in usa");

I am in usa
I am in India
I am in main
I am in India
I am in usa

Above program there are two startup directives which will execute before the main function.

Function name India has priority 105
Function name usa has priority 100 (default)

So usa function will execute first than India function and above program there are two exit directive which will execute after the main function.

Function name India has priority 105
Function name usa has priority 100 (default)

So india function will execute first than usa function.

0 Dislike
Follow 1

Please Enter a comment


Other Lessons for You

Program to swap the value of two variables without using third variable(simplest way)...
int main() { int a=10,b=20; printf("values of a before swap ="%d,a); printf("values of b before swap ="%d,b); a=a+b; b=a-b; a=a-b; printf("******************"); printf("values of a after swap...

Rohan | 17/11/2018

2 0

Advantages of C++ Language
Advantages of C++ - C++ is a profoundly convenient dialect and is frequently the dialect of decision for multi-gadget, multi-stage application advancement. - C++ is a protest situated programming dialect...

C for Begginers
C is an procedure oriented programming language. For any begginer the word program is new. Program: Set of instructions to be followed by machine or computer. Instruction Examples: Arithmetic instruction...

Sonali K. | 13/09/2018

2 0

Creating First Program Using C Language
Step 1: Install and setup Turbo C compiler on your computer. Step 2: Open Turbo C from your Desktop or Programs menu. Select “File” from menu bar and select option “New”. Step...

Dipti S. | 18/12/2017

0 0

Is It Fine To Write “void main()” Or “main()” In C/C++?
The definition: void main() { /* ... */ } Is not and never has been C++, nor has it even been C. See the ISO C++ standard 3.6.1 or the ISO C standard A conforming...

Sunil Yadav | 13/07/2017

0 0

Looking for C Language Classes?

Find best C Language Classes in your locality on UrbanPro.

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you

Find Best C Language Classes?

Find Now » is India's largest network of most trusted tutors and institutes. Over 25 lakh students rely on, to fulfill their learning requirements across 1,000+ categories. Using, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 6.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more