Home › Forums › C Programming › Calling function with main()
- This topic has 3 replies, 3 voices, and was last updated 19 years, 9 months ago by will.
- AuthorPosts
- February 19, 2005 at 12:21 am #1881JAZYY18Participant
hi
Here is program which call function without calling main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687#include<stdio.h><br />#include<conio.h><br />#define FIRST 0<br />#define SECOND 1<br />#define THIRD 2<br /><br />file://Variables<br />int a,b,c,ch;<br />float d;<br />file://Function Prototype<br />void Read();<br />void Operation();<br />void Display();<br />#pragma startup Read 0 file://First_Priority<br />#pragma startup Operation 1 file://Second_Priority<br />#pragma exit Display file://Third_Priority<br />void main()<br />{<br />printf("<br />Enter to main() ");<br />getch();<br />printf("<br />Exit From main() ");<br />getch();<br />}<br />void Read()<br />{<br />clrscr();<br />printf("<br />Enter the value of a : ");<br />scanf("%d",&a);<br />printf("<br />Enter the value of b : ");<br />scanf("%d",&b);<br />}<br />void Operation()<br />{<br />printf("<br />ArithMetic Operations<br />");<br />printf("<hr class="bbcode_rule" />");<br />printf("1 -> Addition<br />");<br />printf("2 -> Subtraction<br />");<br />printf("3 -> Multiplication<br />");<br />printf("<hr class="bbcode_rule" />");<br />scanf("%d",&ch);<br />switch(ch)<br />{<br />case 1:<br />c = a+b;<br />break;<br />case 2:<br />c = a-b;<br />break;<br />case 3:<br />c = a*b;<br />break;<br />}<br />}<br />void Display()<br />{<br />switch(ch)<br />{<br />case 1:<br />printf("<br />The Result (Addition) : %d",c);<br />break;<br />case 2:<br />printf("<br />The Result (Subtraction): %d",c);<br />break;<br />case 3:<br />printf("<br />The Result (Multiplication): %d",c);<br />break;<br />}<br />getch();<br />}<br /><br />/*cool program*/ - February 19, 2005 at 9:27 am #3134msaqibParticipant
spsinghs plz can u give an overview of this program, I mean the flow of the program, So that novice users can understand it.
Thanks - February 23, 2005 at 11:03 pm #3135JAZYY18Participant
hi
here is pragma explanation..
Each implementation of C and C++ supports some features unique to its host machine or operating system. Some programs, for instance, need to exercise precise control over the memory areas where data is placed or to control the way certain functions receive parameters. The #pragma directives offer a way for each compiler to offer machine- and operating system-specific features while retaining overall compatibility with the C and C++ languages. Pragmas are machine- or operating system-specific by definition, and are usually different for every compiler.
Pragmas can be used in conditional statements, to provide new preprocessor functionality, or to provide implementation-defined information to the compiler - February 24, 2005 at 9:53 am #3136willParticipant
Thanks spsinghs for explanations.
- AuthorPosts
- The forum ‘C Programming’ is closed to new topics and replies.