Canalblog
Suivre ce blog Administration + Créer mon blog

FULL PROG

25 juillet 2007

Structure of a program

Published by Juan Soulie
Last update on Apr 24, 2007 at 12:19pm

Probably the best way to start learning a programming language is by writing a program. Therefore, here is our first program:

// my first program in C++

#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World!";
  return 0;
}
Hello World!

The first panel shows the source code for our first program. The second one shows the result of the program once compiled and executed. The way to edit and compile a program depends on the compiler you are using. Depending on whether it has a Development Interface or not and on its version. Consult the compilers section and the manual or help included with your compiler if you have doubts on how to compile a C++ console program.

The previous program is the typical program that programmer apprentices write for the first time, and its result is the printing on screen of the "Hello World!" sentence. It is one of the simplest programs that can be written in C++, but it already contains the fundamental components that every C++ program has. We are going to look line by line at the code we have just written:

// my first program in C++
This is a comment line. All lines beginning with two slash signs (//) are considered comments and do not have any effect on the behavior of the program. The programmer can use them to include short explanations or observations within the source code itself. In this case, the line is a brief description of what our program is.
#include <iostream>
Lines beginning with a pound sign (#) are directives for the preprocessor. They are not regular code lines with expressions but indications for the compiler's preprocessor. In this case the directive #include <iostream> tells the preprocessor to include the iostream standard file. This specific file (iostream) includes the declarations of the basic standard input-output library in C++, and it is included because its functionality is going to be used later in the program.
using namespace std;
All the elements of the standard C++ library are declared within what is called a namespace, the namespace with the name std. So in order to access its functionality we declare with this expression that we will be using these entities. This line is very frequent in C++ programs that use the standard library, and in fact it will be included in most of the source codes included in these tutorials.
int main ()
This line corresponds to the beginning of the definition of the main function. The main function is the point by where all C++ programs start their execution, independently of its location within the source code. It does not matter whether there are other functions with other names defined before or after it - the instructions contained within this function's definition will always be the first ones to be executed in any C++ program. For that same reason, it is essential that all C++ programs have a main function.

The word main is followed in the code by a pair of parentheses (()). That is because it is a function declaration: In C++, what differentiates a function declaration from other types of expressions are these parentheses that follow its name. Optionally, these parentheses may enclose a list of parameters within them.

Right after these parentheses we can find the body of the main function enclosed in braces ({}). What is contained within these braces is what the function does when it is executed.

cout << "Hello World";
This line is a C++ statement. A statement is a simple or compound expression that can actually produce some effect. In fact, this statement performs the only action that generates a visible effect in our first program.

cout represents the standard output stream in C++, and the meaning of the entire statement is to insert a sequence of characters (in this case the Hello World sequence of characters) into the standard output stream (which usually is the screen).

cout is declared in the iostream standard file within the std namespace, so that's why we needed to include that specific file and to declare that we were going to use this specific namespace earlier in our code.

Notice that the statement ends with a semicolon character (;). This character is used to mark the end of the statement and in fact it must be included at the end of all expression statements in all C++ programs (one of the most common syntax errors is indeed to forget to include some semicolon after a statement).

return 0;
The return statement causes the main function to finish. return may be followed by a return code (in our example is followed by the return code 0). A return code of 0 for the main function is generally interpreted as the program worked as expected without any errors during its execution. This is the most usual way to end a C++ console program.

You may have noticed that not all the lines of this program perform actions when the code is executed. There were lines containing only comments (those beginning by //). There were lines with directives for the compiler's preprocessor (those beginning by #). Then there were lines that began the declaration of a function (in this case, the main function) and, finally lines with statements (like the insertion into cout), which were all included within the block delimited by the braces ({}) of the main function.

The program has been structured in different lines in order to be more readable, but in C++, we do not have strict rules on how to separate instructions in different lines. For example, instead of

int main ()
{
  cout << " Hello World ";
  return 0;
}

We could have written:

int main () { cout << "Hello World"; return 0; }

All in just one line and this would have had exactly the same meaning as the previous code.

In C++, the separation between statements is specified with an ending semicolon (;) at the end of each one, so the separation in different code lines does not matter at all for this purpose. We can write many statements per line or write a single statement that takes many code lines. The division of code in different lines serves only to make it more legible and schematic for the humans that may read it.

Let us add an additional instruction to our first program:

// my second program in C++

#include <iostream>

using namespace std;

int main ()
{
  cout << "Hello World! ";
  cout << "I'm a C++ program";
  return 0;
}
Hello World! I'm a C++ program

In this case, we performed two insertions into cout in two different statements. Once again, the separation in different lines of code has been done just to give greater readability to the program, since main could have been perfectly valid defined this way:

int main () { cout << " Hello World! "; cout << " I'm a C++ program "; return 0; } 

We were also free to divide the code into more lines if we considered it more convenient:

int main ()
{
  cout <<
    "Hello World!";
  cout
    << "I'm a C++ program";
  return 0;
}

And the result would again have been exactly the same as in the previous examples.

Preprocessor directives (those that begin by #) are out of this general rule since they are not statements. They are lines read and processed by the preprocessor and do not produce any code by themselves. Preprocessor directives must be specified in their own line and do not have to end with a semicolon (;).

Comments

Comments are parts of the source code disregarded by the compiler. They simply do nothing. Their purpose is only to allow the programmer to insert notes or descriptions embedded within the source code.

C++ supports two ways to insert comments:

// line comment
/* block comment */

The first of them, known as line comment, discards everything from where the pair of slash signs (//) is found up to the end of that same line. The second one, known as block comment, discards everything between the /* characters and the first appearance of the */ characters, with the possibility of including more than one line.
We are going to add comments to our second program:

/* my second program in C++
   with more comments */


#include <iostream>
using namespace std;

int main ()
{
  cout << "Hello World! ";     // prints Hello World!
  cout << "I'm a C++ program"; // prints I'm a C++ program
  return 0;
}
Hello World! I'm a C++ program

If you include comments within the source code of your programs without using the comment characters combinations //, /* or */, the compiler will take them as if they were C++ expressions, most likely causing one or several error messages when you compile it.

Publicité
Publicité
18 juillet 2007

Généalogie de Geni

Il y a quelques temps j'ai découvert Geni.com, un site vraiment passionnant pour ajouter online les membres de la famille, et eux aussi peuvent ajouter à leur tour, inviter d'autres membres de la famille à ajouter et ainsi de suite.... Je ne m'en lasserai jamais, c'est dans mes veines. J'ai toujours des choses, et des personnes à ajouter dedans!!!

Voir geni.com

12 juillet 2007

Toutes les offres

Lien vers les Offres d'emplois (Site EPFL)

11.07.2007 Ingénieur réseau
Fibre Lac SA
Vevey
Suisse
11.07.2007 computer scientist for a period of 14 months
Université de Lausanne / Ecole des sciences criminelles
Lausanne
Switzerland
11.07.2007 Part-time French-speaking technical e-mail support (telework)
futureLAB AG
Winterthur
Switzerland
26.06.2007 Recherchons des profiles IT Junior/Senior
Ads-Click
Genève
Suisse
22.06.2007 Patent Examiner
SpenglerFox
22.06.2007 Operations and Support Engineer
24/7 Real Media Europe
Ecublens
Switzerland
22.06.2007 Consultant
Innovatica
07.06.2007 Consultants Juniors, Seniors & Managers SCM (H/F)
Argon Consulting
Levallois-Perret
France
07.06.2007 SCM Consultants, Juniors, Seniors and Managers (for Bahrain) (W/M)
Argon Consulting
Levallois Perret Cedex
France
05.06.2007 Développeur(se) JAVA/J2EE/WEB2
Adonys Group
Carouge
Suisse
05.06.2007 Developeur VB.Net
Triamun AG
Gümligen
Suisse
04.06.2007 Budget Systems Analyst
World Meteorological Organization
Genève 2
Switzerland
30.05.2007 System Engineer
PSideo SA
Carouge
Suisse
30.05.2007 Proposition d'un sujet de thèse
France Telecom
Rennes
France
30.05.2007 Proposition de thèse
France Telecom
Rennes
France
29.05.2007 Ingénieur en biométrie et sécurité
Sensometrix Sàrl
Chêne-Bougeries
Suisse
29.05.2007 Develop and support Data Warehouse deliverables
AdsClick
Genève
Suisse
21.05.2007 Postdoctoral reserach fellowships or young researchers
European Space Agency
AZ Noordwijk ZH
The Netherlands
21.05.2007 Cisco Associate Systems Engineer
Cisco
London
England
15.05.2007 Development Logiciel
Starcut
New York
Etats Unis
07.05.2007 Consultants Juniors, Seniors & Managers SCM
Argon Consulting
Levallois-Perret
France
07.05.2007 Consultant Senior (Bahreïn) SCM (f/h)
Argon Consulting
Levallois-Perret
France
07.05.2007 Jeune informaticien pour stage de formation au sein d'un département informatique bancaire
Espirito Santo
Lausanne
Suisse
07.05.2007 Application Engineer Train Traffic Control
Systransis AG - Transport Information Systems
Zug
Switzerland
03.05.2007 3D Graphics-Mathematical Programmer
CSIRO
Australia
03.05.2007 System Administrator Product Developer
TouchMind
Yverdon
Switzerland
01.05.2007 Java Programmer/Analyst - UNCTAD (United Nations)
United Nations
25.04.2007 Manager Engineering
Cisco Systems International Sàrl
Bussigny-près-Lausanne
Switzerland
25.04.2007 Software Engineer, Human Computer Interface
Cisco Systems International Sàrl
Bussigny-près-Lausanne
Switzerland
25.04.2007 Software Engineer, Web Developer
Cisco Systems Internationl Sàrl
Bussigny-près-Lausanne
Switzerland
25.04.2007 Junior Software Engineer, Web Developer
Cisco Systems International Sàrl
Bussigny-près-Lausanne
Switzerland
25.04.2007 Responsable des systèmes d’information en téléphonie santé
INSTITUT NATIONAL DE PREVENTION ET D'EDUCATION POUR LA SANTE (INPES),
France
24.04.2007 Ingenieur En Developpement Java J2EE
MBA Michael Bailey Associates
11.04.2007 Executive MBA Program Learning Manager
IMD International
Lausanne
Switzerland
03.04.2007 C# .NET server developer
connvision AG
Zurich
Switzerland
03.04.2007 Ingénieur Support et Développement J2EE
Unipro SA
Genève
Suisse
27.03.2007 Associate Systems Engineer
Cisco
London
England
27.03.2007 Associate Sales Representative
Cisco
London
England
26.03.2007 Solution Architect
Ericsson AG
Bern
Switzlerand
26.03.2007 Service Layer Sales Manager
Ericsson AG
Bern
Switzerland
26.03.2007 Sales & Business Development Manager
Ericsson AG
Bern
Switzerland
26.03.2007 Solution Manager
Ericsson AG
Bern
Switzerland
26.03.2007 Solution Integrator
Ericsson AG
Bern
Switzerland
26.03.2007 Associate Principal/Principal Business Consultant
Ericsson AG
Bern
Switzerland
26.03.2007 Projet de 6 mois (peut déboucher sur un engagement à long terme)
Fastcom Technology SA
Lausanne
Switerzland
16.03.2007 Un(e) ingénieur(e) informaticien(ne) ou microtechnicien(ne)
EPFL
Lausanne
Suisse
12.03.2007 Software Process & Quality Manager
Honeywell Switzerland Sarl
Ecublens
Switzerland
12.03.2007 Software Process & Quality Focal
Honeywell Switzerland Sarl
Ecublens
Switzerland
12.03.2007 Global Technical Manager
Honeywell Switzerland Sarl
Ecublens
Switzerland
19.02.2007 Consultant - Teamleader Frimware
Altran A.G.
Lausanne
Suisse
13.02.2007 Java developer
Current BioData Ltd
Geneva
Switzerland
12.02.2007 Senior Associate
Delta Partners
Dubai
United Arab Emirates
12.02.2007 Analyst
Delta Partners
Dubai
United Arab Emirates
05.02.2007 Image Optimisation Specialist
Seitz Imaging GmbH
Dietlikon
Switzerland
02.02.2007 Intern Technical Translator
Apple Inc.
Cupertino
USA
25.01.2007 Information Security Project Manager
Ilion Security SA
Geneva
Switzerland
22.01.2007 Programmer/Analyst - UNCTAD (United Nations)
United Nations Conference on Trade and Development
Geneva
Switzerland
22.01.2007 PhD position in Computer Vision at Deutsche Telekom Laboratories, Berlin, Germany
Deutsche Telekom Laboratories
Berlin
Germany
22.01.2007 Développeur
SymptoTherm Foundation
Morges
Switzerland
22.01.2007 Consultant Senior SCM
Argon Consulting
Levallois-Perret
France
22.01.2007 Senior Analyst Prorammer
European Dynamics SA
Maroussi, Athens
Greece
10.01.2007 Software Engineer - Wireless Systems
Nomor Research GmbH
München
Germany
10.01.2007 Research Engineer - Future Wireless Systems (LTE/HSDPA)
Nomor Research GmbH
München
Germany
10.01.2007 IT Support Engineer - Wireless Systems
Nomor Research GmbH
München
Germany
12 juillet 2007

Emploi : IT Junior/Senior

Titre de l'offre : Recherchons des profiles IT Junior/Senior
Date : 26/06/2007
Description de l'offre : Entreprise active dans le domaines de la publicité online et suite à la levée de fond de 4.5 millions nous recherchons les personnes suivantes

DBA Manager
DBA Junior
C++ Win32/Vista
QA Manager
JAVA
Java / J2ee Intermediate/Junior
PHP
GUI
Ajax/Javascript specialistes

Pour plus d'info, http://www.ads-click.com et http://www.ads-click.com/jobs.html
Nos bureaux sont à 5-10 minutes de l'aéroport de Genève.
(40 minutes depuis Lausanne en train)

Pourquoi venir?
- Esprit encore Startup.
- Plan de Stock Options.
- Sécurité de l'emploi (nous venons de lever 4.5 mio).
- Horaires classique de l'industrie.
- Salaire dans les normes de l'industrie.
- Très orienté R&D et Prototypage.

N'hésitez pas à proposer votre candidature, même si votre profil ne correspond pas tout à fait.
Qualifications particulières :
Nom de l'entreprise : Ads-Click
Site Web : http://www.ads-click.com
Adresse de l'entreprise : ICC
Route de Pré-Bois, 20
1215  Genève
Suisse
Personne de contact : Gabriel Kein
Tél. : +41 22 791 73 80
Fax :
Email : gabriel.klein@ads-click.com
12 juillet 2007

Emploi : Technical e-mail support

Titre de l'offre : Part-time French-speaking technical e-mail support (telework)
Date : 11/07/2007
Description de l'offre : We are looking for a part-time technical support person to support French-speaking customers of our online media/photo management system via e-mail.

Ideally the candidate would also be able to support customers in English and possibly German.

This is an ideal side job for a student. After initial training at our location in Winterthur, the work can be done remotely over the Internet from any computer with a web browser.

Since this is technical support, we would prefer a student of computer science or electrical engineering or another technical field. Experience with and/or interest in digital photography and web technologies are also a plus.
Qualifications particulières : Ability to explain usage of the system to end users. Good written communication skills in French and English, if possible German.
Nom de l'entreprise : futureLAB AG
Site Web : http://www.futurelab.ch
Adresse de l'entreprise : Schwalmenackerstrasse 4
8400  Winterthur
Switzerland
Personne de contact : Marc Liyanage
Tél. : +41 76 554 22 10
Email : mliyanage@futurelab.ch
Publicité
Publicité
12 juillet 2007

Emploi : computer scientist

Titre de l'offre : computer scientist for a period of 14 months
Date : 11/07/2007
Description de l'offre : Seeking a computer scientist (preferably full time) for a period of 14 months to work on a research project devoted to the statistical analysis of partial fingerprints. The project is funded by the TSWG (US Dept. of Defense).

The School of Criminal Sciences (ESC) and its Institute of forensic sciences of the University of Lausanne is seeking an experienced individual to join a team working on a project financed by the US Technical Support Working Group (www.tswg.gov). The project will last for a period of 14 months.

The ESC has a research program on fingerprint statistics applied to forensic science since 1995. Following research already funded by TSWG (2003-2005), the ESC is currently working on a follow-up project aiming at exploring topological models for assessing fingerprint variability. You will join this research team.

We are looking for an enthusiastic team player to join a group devoted to fingerprint statistics research. A full degree in computer science, image or signal processing is required. For this challenging and rewarding role, postgraduate experience of image processing or pattern recognition would be a real advantage, as would a relevant PhD.

You will bring to the team expertise in the use and implementation of various image processing methods for fingerprint image analysis. The environment for development will be Matlab® and Flash® (Actionscript). In addition the candidate is expected to show ability to work independently and effectively within a team (with a forensic scientists and a statistician) and will need the ability to work to a highly structured schedule in order to meet demanding deadlines. Good communication skills (written and oral) and knowledge of English will be beneficial.

The work location is our institute in Lausanne on the University campus; the planned starting date is September 2007.

The salary for this position will be circa CHF 74’000 per year (full time) depending on relevant qualifications and experience.

Closing date for receipt of written applications will be 20th July 2007.
Qualifications particulières : You have a strong background in computer science, preferably with emphasis on image processing, feature extraction and possibly morphing / warping algorithms. You are willing to take the lead in developing algorithms to extract topological information from full and partial fingerprint images. You also have experience in designing graphical user interface.
Nom de l'entreprise : Université de Lausanne / Ecole des sciences criminelles
Site Web : http://www.unil.ch/esc
Adresse de l'entreprise : Institut de Police Scientifique
Batochime / Quartier Sorge
1015  Lausanne
Switzerland
Personne de contact : Prof. C. Champod
Tél. : +41 21 692 46 29
Email : christophe.champod@unil.ch
11 juillet 2007

FileMaker Pro 8.5

Tous les détails sur FileMaker Pro (je commence tout juste à l'utiliser aujourd'hui).

Société proposant les services sur FileMaker : http://www.actived.fr

11 juillet 2007

Offres d'emplois : Ingénieur réseau

Titre de l'offre : Ingénieur réseau
Date : 11/07/2007
Description de l'offre : Vous êtes responsable d'assurer le bon fonctionnement de notre réseau IP/MPLS au niveau Suisse

• Validation technique, planification et suivi de projets
• Supervision des sous-traitants pour la maintenance et le support
• Maintenance préventive, contrôle des SLA
• Mise en route des clients
• Support technique pour nos clients
Qualifications particulières : • Etudes universitaires en informatique ou telecom • Expérience dans le domaine telecom/IT • Connaissances IP, MPLS, SNMP, Unix • Administration de switchs et de routeurs • Connaissances LAN • Notions éléctricité basse tension et facility management • Organisé, pro-actif et indépendant • Très bon Anglais obligatoire, connaissances d'Allemand un plus • Nationalité Suisse/Européenne ou permis de travail Si l'opportunité de rejoindre une structure flexible et dynamique dans le domaine en pleine expansion des réseaux haut-débits vous intéresse, n'hésitez pas à nous envoyer votre dossier, par email (info@fibrelac.com) ou par courrier (Ressources Humaines, Fibre Lac SA, Paul-Cérésole 24, 1800 Vevey, Suisse). Toutes les candidatures reçues seront traitées avec la plus grande confidentialité.
Nom de l'entreprise : Fibre Lac SA
Site Web : http://www.fibrelac.com
Adresse de l'entreprise : 1800  Vevey
Suisse
Personne de contact : Olivier Crochat
Tél. : +41 (0)21 923 31 13
Fax :
Email : info@fibrelac.com
Publicité
Publicité
Publicité
Archives
FULL PROG
Derniers commentaires
Publicité