What is the function of 'main' in 'c' programming?
int main (void)
In the above statement, void represent??
Member • Jun 12, 2012
void represents that main function is not taking any argument while its execution. You can even skip that void and write main(). main takes two arguments like main(int argc, char *argv[])aarthivgwhat is the function of 'main' in 'c' programming?
int main (void)
In the above statement, void represent??
Member • Jun 12, 2012
Member • Jun 12, 2012
Is arguments and parameter, both mean the sameNick_Sharmavoid represents that main function is not taking any argument while its execution. You can even skip that void and write main(). main takes two arguments like main(int argc, char *argv[])
where argc is the counter that counts the number of arguments passed to main and argv means argument vector which stores all the arguments passed in the form of a character array
Member • Jun 12, 2012
Member • Jun 12, 2012
sorry, its int main(void)ianoopvoid main() means... this function is not returning any value.
int void main() is a illegal declaration .
either it could be int main() , which must have a integer type return statement as last line of function
or another type of return.
Member • Jun 12, 2012
that means main function is not taking any argument and will return a integer type value.aarthivgsorry, its int main(void)
Member • Jun 12, 2012
ya I have too. I don't have the software😔ianoopthat means main function is not taking any argument and will return a integer type value.
why should not you make some programs about your doubts.compiler itself will tell you .
Member • Jun 12, 2012
Yeah they are same...!aarthivgIs arguments and parameter, both mean the same
Member • Jun 13, 2012
Take a look at this video:aarthivgya I have too. I don't have the software😔
Member • Jun 13, 2012
<return-type> function-name(<list-of-arguments>)Here, return-type can be of any data-type, like int or char etc.. It can also be "void" which means that function doesn't return anything.
Member • Jun 13, 2012
Member • Jun 13, 2012
return type depicts the type of value that your function returns. return statement returns a value to the caller function. Consider following programaarthivgreturn statement means?
main() { int c; c=sum(); printf("%d",c); return 0; } int sum() { int a=1,b=2; return(a+b); }In the above program, return(a+b) is called return statement as it returns an integer value to the calling function that is main. Now as an integer value is returned, there must be a variable to hold the returned data and even that must be of the same type as the type of value returned i.e. int in this case..
Member • Jun 13, 2012
Member • Jun 13, 2012
There is no match between main and array. They are two different things all together. main() marks the beginning point of execution of a program whereas array is simply a collection of objects of same type which are referred under a same name whose memory is allocated statically. main() is a function whereas array is a collection of elements of the same data typeherreyWell how differ main from array?
I know in C++ array are so important so can you explain its difference?
Member • Jun 13, 2012
return 0 implies ?Nick_Sharmareturn type depicts the type of value that your function returns. return statement returns a value to the caller function. Consider following program
main() { int c; c=sum(); printf("%d",c); return 0; } int sum() { int a=1,b=2; return(a+b); }In the above program, return(a+b) is called return statement as it returns an integer value to the calling function that is main. Now as an integer value is returned, there must be a variable to hold the returned data and even that must be of the same type as the type of value returned i.e. int in this case..
Member • Jun 13, 2012
Member • Jun 13, 2012
Member • Jun 14, 2012
getch() is used to read a character from keyboard...aarthivgthen getch() is used for?
Member • Jun 14, 2012
Member • Jun 14, 2012
Here is the mistake. & is called address operator. So when you are printing &sub, you are printing the address at which the result is stored and not the result. replace the above line withaarthivgprintf(" %d",&sub);
Member • Jun 14, 2012
ya...thanks... got itNick_SharmaHere is the mistake. & is called address operator. So when you are printing &sub, you are printing the address at which the result is stored and not the result. replace the above line with
printf("%d",sub);
This will make your program work perfectly..
Member • Jun 14, 2012
Member • Jun 14, 2012
System() is used to call OS functions. System("pause") causes the DOS output screen to be held. It does the same function as getch() when used as the last line in program. If you don't write getch() or System("pause") in the earlier versions of C then the black screen just flashes and then disappears. Then you must press alt+f5 to view the output. System("pause") and getch() prevents the flashing of screen and holds it till a character is enteredaarthivgwhat is the use of SYSTEM("PAUSE") command
Member • Jun 14, 2012
Member • Jun 17, 2012
Member • Jun 17, 2012
Member • Jun 18, 2012
Member • Feb 16, 2013
Member • Mar 4, 2013
Member • Mar 14, 2013
Member • Apr 4, 2013
aarthivgwhat is the function of 'main' in 'c' programming?
int main (void)
In the above statement, void represent??
Member • Apr 4, 2013
Not always!!😎 Actually avoid semicolon in case of loops and conditional statements(ie if blocks)Sanyam Khuranaint main (void); (always terminate a statement with a semicolon) 😛
int i=0; while (i<10); i++;. Big Blunder!!😉😁
Member • Apr 4, 2013
Member • Apr 4, 2013
Member • Apr 4, 2013
aarthivg#include<stdio.h>
#include<stdlib.h>
int main()
{
int a,b,sub;
printf(" enter the value of a");
scanf("%d",&a);
printf("enter the value of b");
scanf("%d",&b);
sub=a-b;
printf(" %d",&sub); //error//
return 0;
}
just tried out a simple program.... but cant able to get the output... whats wrong in it
for 3-2 ... getting output as 9016
Member • Apr 4, 2013
to the system. Or to the caller.lit-857int main() return value to whom??
Member • Apr 5, 2013
haha, yes that's true, I was talking about General statements 😛rahul69Not always!!😎 Actually avoid semicolon in case of loops and conditional statements(ie if blocks)
eg:int i=0; while (i<10); i++;. Big Blunder!!😉😁
Member • Apr 5, 2013
Member • Apr 6, 2013
What do you mean?lit-857who call the main function
Member • Apr 6, 2013
ianoopvoid main() means... this function is not returning any value.
int void main() is a illegal declaration .
either it could be int main() , which must have a integer type return statement as last line of function
or another type of return.
Member • Apr 6, 2013
its the operating system...lit-857who call the main function
Member • Apr 6, 2013
As per my knowledge, RTE calls the main function & not just OS.Vishal0203its the operating system...
and main() is always "public" so that it is visible to the OS
Member • Apr 6, 2013
Member • Apr 6, 2013
Member • Apr 6, 2013
Member • Apr 7, 2013
Member • Apr 7, 2013
A c program is compiled into assembly code(and finally into binary). The main() function enables the compiler to put the code present in this method as first line in the compiled version - the entry point of the program when you execute it.lit-857plz explain it i can't understend
Member • Apr 7, 2013
Member • Apr 11, 2013
Member • Apr 11, 2013
ummm... do you have a text Book to learn C??lit-857wts d/f b/w celloc() and melloc() fn
Member • Apr 12, 2013
At the same time please avoid SMS language cause it can lead to misconception among uslit-857wts d/f b/w celloc() and melloc() fn