Lab 01: Create Your First C Console Program

Objective

  • Learn how to create a console project in Visual C++ or C++Builder IDE

Software Requirement

  • Visual C++ 2017 or newer edition
  • Or C++ Builder 10.3.x or newer edition
  • Or XCode in Mac OS X system

Background Information

There are two types of C/C++ compilers, each of which has advantages and disadvantages:

  1. Command-line C compilers
  2. IDE (Integrated Development Environment) or Windows C/C++ compilers

Command-Line C Compilers

If you use a command-line C compiler to compile and execute a C program, you have to go through the following steps:

  1. Write the C code in a text editor or word processor.
  2. Save the file as myfile.c file in your C project folder.
  3. Compile the code to a computer-executable program by entering a compiler command at a command prompt, or console window.
    For GUN C compiler: gcc -Wall -o myfile myfile.c
    For Microsoft Visual C++ command-line compiler: cl myfile.c
    For C++Builder compiler: bcc32 myfile.c
  4. Execute the program by entering
    myfile
    at the command prompt. Then you should see the program's results on the screen.

You can use any text editor or code editor that you prefer using with the command-line C compiler. Here are some useful text editors that most programmers are like:

IDE C/C++ Compilers

Integrated Development Environment or IDE for short is an application or software which programmers use for programming. It helps a programmer to program easily by providing all comprehensive facilities required for the development of software. IDE can improve the productivity of a programmer or developer because of its fast setup and various tools. Without this, a programmer takes a lot of time deciding various tools to use for their tasks.

Mainly, an IDE includes 3 parts: source code editor, build automation tool (compiler) and a debugger. The source code editor is something where programmers can write the code, whereas, build automation tool is used by the programmers for compiling the codes and the debugger is used to test or debug the program in order to resolve any errors in the code. Furthermore, these IDEs also comes with additional features like object and data modeling, unit testing, source code library, and a lot more.

As of now, several IDEs are available for various programming languages like Python, C++, Java. JavaScript, R, and others. The modern IDEs even possess intelligent code completion for maximizing the programmer's productivity.

IDE C compilers have the advantages:
  • The IDE compilers usually have a built-in code editor that is colorized for C/C++. That means the C/C++ keywords are in one color (like blue), text in text strings may be in another color (like red), comments may be in green, while another text is in black. And if you misspell a keyword in C/C++ or miss a quotation mark, this becomes immediately obvious.
  • Takes less time and effort- It includes various tools and features that help to prevent mistakes, organizes resources and provides shortcuts.
  • It allows quick navigation to the type.
  • Programmers can quickly navigate to other members by using hyperlinks.
  • IDEs organize imports and can add appropriate imports.
  • It can give warning in case of any errors or mistakes.
  • IDEs are great for generating code or completing the code depending upon previous codes.
  • These environments make the unit test's running easy.
Disadvantages of IDE C/C++ compilers are:
  • Commercial IDE C/C++ compilers cost money.
  • Usually, you must install it on your own computer, and require more disk space to install the software.
  • Using a command-line compiler is much faster than an IDE.
  • In UNIX/Linux computer system, you can not operate the IDE over the telnet interface.

Lab Experiment

Now you will learn how to create a new project for a windows console application in the IDE

Run the code and capture the screen. Paste it to your report.

 

 


Extra Useful Information for You!