Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Can someone explain me the method of writing a C++ program?

Computer Science
See more answers at
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.

Get this expert

answer on brainly


Get your free account and access expert answers to this and thousands of other questions

"->" 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 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++
Thanx a lot.
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)

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

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.
It's non-standard though and Stroustrup advises against it: here are some more reasons:
OK.Good info.....

Not the answer you are looking for?

Search for more explanations.

Ask your own question