- This topic has 3 replies, 3 voices, and was last updated 17 years, 11 months ago by .
Viewing 3 reply threads
Viewing 3 reply threads
- The forum ‘C Programming’ is closed to new topics and replies.
Home › Forums › C Programming › Calling function with main()
hi
Here is program which call function without calling main()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
#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*/ |
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
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
Thanks spsinghs for explanations.