Showing posts with label Cplusplus. Show all posts
Showing posts with label Cplusplus. Show all posts

Thursday, September 24, 2009

Function in C++

What is a ?

A is a block of code that has a name and it has a property that it is reusable i.e. it can be executed from as many different points in a C Program as required.
groups a number of program statements into a unit and gives it a name. This unit can be invoked from other parts of a program. A computer program cannot handle all the tasks by it self. Instead its requests other program like entities – called functions in C – to get its tasks done. A is a self contained block of statements that perform a coherent task of same kind
The name of the is unique in a C Program and is Global. It neams that a can be accessed from any location with in a C Program. We pass information to the called arguments specified when the is called. And the either returns some value to the point it was called from or returns nothing.
We can divide a long C program into small blocks which can perform a certain task. A is a self contained block of statements that perform a coherent task of same kind.

Structure of a

There are two main parts of the . The header and the body.
int sum(int x, int y)
{
 int ans = 0;  //holds the answer that will be returned
 ans = x + y; //calculate the sum
 return ans  //return the answer
}

Header

In the first line of the above code
int sum(int x, int y)
It has three main parts
  1. The name of the i.e. sum
  2. The parameters of the enclosed in paranthesis
  3. Return value type i.e. int

Body

What ever is written with in { } in the above example is the body of the .

Prototypes

The prototype of a provides the basic information about a which tells the compiler that the is used correctly or not. It contains the same information as the header contains. The prototype of the in the above example would be like
int sum (int x, int y);
The only difference between the header and the prototype is the semicolon ; there must the a semicolon at the end of the prototype.

Fahrenheit to celsius conversion












CSE 112 Answer to your assignment.
formula:
for -- Celsius=(5/9) * (Farenheit - 32)

for -- Farenheit =(9/5) * ( Celcius + 32)

Wednesday, September 23, 2009

for loop statements

CSE 112 Students!!! please review this for loop statement click the url address below.

http://www.hitmill.com/programming/cpp/forLoop.htm

Wednesday, August 26, 2009

c++ switch statement example

1:// This is a single line comment
2:// Demonstrates switch statement
3:// This switch example does not used with the break keyword.
4:#include
5:
6:int main()
7
8:int number;
9:"Enter a number between 1 and 5:
10:
11:switch (number)
12:
13:case 0: "Too small, sorry!";
14:break;
15:case 5:
16:case 4: "Nice Pick!\n"; // fall through
17:case 3: "Excellent!\n"; // fall through
18:case 2: "Masterful!\n"; // fall through
19:case 1: "Incredible!\n"
20:
21:default: "Too large!\n";
22:break;
23:
24:cout "\n\n";
25:return 0

Monday, August 24, 2009

Phases of C++ Programs


Phases of C++ Programs
1.Edit 
2. Preprocess
3. Compile
4. Link
5. Load
6. Execute