May 26, 2010 Dev C First Program in Urdu 1st Program Start Coding - Duration: 8:56. Pak Academy79 21,140 views. Feb 28, 2015 Here we will write our first C program, compiler it and run it. We will use Dev C to write and run the program. We will see usage of prinft function, header files, stdio.h, conio.h. Nov 29, 2016 Server and Application Monitor helps you discover application dependencies to help identify relationships between application servers. Drill into those connections to view the associated network performance such as latency and packet loss, and application process resource utilization metrics such as CPU and memory usage.
![]()
C++ProgrammingObject Oriented Programming
So you've decided to learn how to program in C++ but don't know where to start. Here's a brief overview of how you can get started.
Get a C++ Compiler
This is the first step you'd want to do before starting learning to program in C++. There are good free C++ compilers available for all major OS platforms. Download one that suits your platform or you can use the tutorialspoint.com's online compiler on https://www.tutorialspoint.com/compile_cpp_online.php
Write a C++ program
Now that you have a compiler installed, its time to write a C++ program. Let's start with the epitome of programming example's, it, the Hello world program. We'll print hello world to the screen using C++ in this example. Create a new file called hello.cpp and write the following code to it −
Let's dissect this program.
Line 1− We start with the #include<iostream> line which essentially tells the compiler to copy the code from the iostream file(used for managing input and output streams) and paste it in our source file. Header iostream, that allows performing standard input and output operations, such as writing the output of this program (Hello World) to the screen. Lines beginning with a hash sign (#) are directives read and interpreted by what is known as the preprocessor.
Line 2− A blank line: Blank lines have no effect on a program.
Line 3− We then declare a function called main with the return type of int. main() is the entry point of our program. Whenever we run a C++ program, we start with the main function and begin execution from the first line within this function and keep executing each line till we reach the end. We start a block using the curly brace({) here. This marks the beginning of main's function definition, and the closing brace (}) at line 5, marks its end. All statements between these braces are the function's body that defines what happens when main is called.
Line 4−
This line is a C++ statement. This statement has three parts: First, std::cout, which identifies the standard console output device. Second the insertion operator << which indicates that what follows is inserted into std::cout. Last, we have a sentence within quotes that we'd like printed on the screen. This will become more clear to you as we proceed in learning C++.
In short, we provide a cout object with a string 'Hello worldn' to be printed to the standard output device.
Note that the statement ends with a semicolon (;). This character marks the end of the statement
Compile the Program
Now that we've written the program, we need to translate it to a language that the processor understands, ie, in binary machine code. We do this using a compiler we installed in the first step. You need to open your terminal/cmd and navigate to the location of the hello.cpp file using the cd command. Assuming you installed the GCC, you can use the following command to compile the program −
This command means that you want the g++ compiler to create an output file, hello using the source file hello.cpp.
Run the program
Now that we've written our program and compiled it, time to run it! You can run the program using −
Output
You will get the output−
It is time to create your C hello world program. By tradition, a 'Hello, world!' program just prints that greeting on the screen. This is usually the first program that any developer creates. It serves two purposes:
In this lesson, I will show you how to create your first program for each of the environments from the previous lesson. You will pick and create the program for the IDE that you chose. To create a program you will:
C 'Hello, world!'
No matter which environment you use, the code forthis example is the same:
I will show you how to write compile and run the code in the IDEs that we looked at in the last lesson:
Visual Studio
I am using Visual Studio Community 2015, but the process is very similar to previous versions(both Express and Professional editions).
Every program in Visual Studio is created within a project. To create your C hello world program, create a new project:
1. Open Visual Studio and go to File->New->Project
If this is a new installation, it is possible that the template component is not installed yet. If that is the case, double click on the “Install Visual C++” text to add the component.
You have just created a new empty project. You can see its contents in the “Solution Explorer”. The solution explorer is located to the right, by default.
Now you are ready to run your C Hello World program!
The result looks like this:
Code::Blocks
To compile and run code you need a compiler. Make sure you havethe Code::Blocks distribution that includes the GCC, otherwise youneed to install a compiler manually.
Code::Blocks allows you to create a program in several ways.
The first two methods are convenient only if your program consists of just 1-2-3 files. If your program has more files it is preferred to put them in a project, because it is easier to navigate.
Let's create your first C project! StartCode::Blocks and from nemu File create a new porject:
Now in the left side of the screen go to Projects in the 'Management' sub-window. Expand your new project and its folder 'Sources'. You will see that Code::Blocks automatically added a new source file 'main.c'. Double click it, to open it.
You see? The 'hello-world' code is already there ;)
It is time to compile and run your first C program. Go to menu Build->'Build and Run' or just press F9 and then OK, when you are asked if you want to build the project.
Dev-C++
If you downloaded a distribution without a compiler, you need to install one manually.
Thereare two ways to create our “C hello world” program in Dev-C++:
Fora this short program it is easier to choose the first option.However, later for programs with more files it is better to use aproject. Here is how to create a C project in Dev Cpp:
In the next window just click 'Save' to save the project files in the default location.
Now your project is created and it contains one source file:
GeanyInstall a compiler (GCC in this case)
Before you can compile and run your C hello world, you need to install a C compiler. For instance to install the GCC in any Debian based distribution, for instance Ubuntu, do the following:
Create the C Hello World program
In Geany you can:
I will show you the second option:
This will generate a new C source file. It will start with a 20 row comment(the red text starting with /* and ending with */) that you can delete right away.
Add the line
printf('Hello, world!n'); between the opening curly bracket '{' and the line 'return 0;'.
Now you just need to build and execute the file:
When the build is done, you will see the message 'Compilation finished successfully.' in the Compiler section below the code.
Now press F5 or the 'Execute' button to start the program. You will see a console that displays the 'Hello, world!' string
How To Write Your First Program In Dev C++
You have just created your C Hello World program! Your development environment is working and tested, so you are ready to continue with the actual part of the basic C tutorial.
My First C++ Program
In the next lesson you will see what is the typical structure of a C program. To explain it, I will use the example from this lesson.
Write First Program In Dev C ExampleC Programming › First Program In CC tutorial › Hello, world!How To Write A Program In Dev C++Please enable JavaScript to view the comments powered by Disqus.Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |