anonymous
  • anonymous
Can someone explain me the method of writing a C++ program?
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
"->" is used to separate code from text .It is not used in C++(for this purpose) ->#include 1)# is a pre-processor indicator 2)include is a pre processor command to "add" a file to your program. 3)<___> file name should come in pointing brackets. 4)iostream.h is the file which allows us to give output or take input. ->void main() -> { ->(body/commands/statement) -> } 1)void is a data type .It indicates that the function (main) will return nothing. other data types are int(for digits),char(for characters),float(for decimals). 2)main() is a function. generally functions are called by writing their name but main() is special is the first one to be called by the compiler itself.You can also write your own functions in C++. 3){} are also called blocks and contains the body of the function. 4)The empty space in the body is used to write commands. ->cout<<"Hi"; 1)cout<< is a keyword in iostream.h file that allows us to print output. 2)Anything to be printed comes within the " ". 3)Every C/C++ command ends with ; ->int v; v=5; 1)int is the data type for digits, 2)v is a variable.int indicates that it can hold only digits. 3)v is assigned the value 5. ->cin>>v; 1)cin>> is a keyword in iostream.h to take a value from user and store it in v. The value v can hold depends on its data type. Sample Code: ->#include ->void main() -> { ->int no; ->cout<<"Enter your number : "; ->cin>>no; ->// Comments are written like this in c++ ->//coments are ignored by the compiler ->// to leave a space of a line in c++ use \n ->cout<<"\nWelcome number "< } ALSO TRY THIS: a complete guide which will make you comfortable with theory part and understanding of C++ http://www.cplusplus.com/doc/tutorial/introduction/
anonymous
  • anonymous
Thanx a lot.
anonymous
  • anonymous
void main? why? the C++ standard mandates that main() has an int return type (unless you're developing under some OS which cannot handle return values)

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
I prefer void over int for main though it does not makes any difference.Its just if you use int you will have to write "return 0;" at the end which is equivalent to void.I prefer int in functions with calculations but for a code such as : cout<<"Hello World"; it would make no difference in such cases.
anonymous
  • anonymous
It's non-standard though and Stroustrup advises against it: http://www2.research.att.com/~bs/bs_faq2.html#void-main here are some more reasons: http://users.aber.ac.uk/auj/voidmain.shtml
anonymous
  • anonymous
OK.Good info.....

Looking for something else?

Not the answer you are looking for? Search for more explanations.