Online Tutor
Sunday, 29 May 2016
Hye everyone! Today we will learn about data types and variable who's used in various languages.so first start with data types
C++ Data Types::
While doing programming in any programming language, you need to use various variables to store various information. Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.
You may like to store information of various data types like character, wide character, integer, floating point, double floating point, boolean etc. Based on the data type of a variable, the operating system allocates memory and decides what can be stored in the reserved memory.
Primitive Built-in Types:
C++ offer the programmer a rich assortment of built-in as well as user defined data types. Following table lists down seven basic C++ data types:
Type: Keyword:
Boolean bool
Character char
Integer int
Floating float
Double double
Valueless void
Wide wchar_t
Variables definition : Variables is a memory alocation in RAM.
Variable Declaration in C++:
A variable declaration provides assurance to the compiler that there is one variable existing with the given type and name so that compiler proceed for further compilation without needing complete detail about the variable. A variable declaration has its meaning at the time of compilation only, compiler needs actual variable definition at the time of linking of the program.
A variable declaration is useful when you are using multiple files and you define your variable in one of the files which will be available at the time of linking of the program. You will use extern keyword to declare a variable at any place. Though you can declare a variable multiple times in your C++ program, but it can be defined only once in a file, a function or a block of code.
ExAmple:
include <iostream>
using namespace std;
// Variable declaration:
extern int a, b;
extern int c;
extern float f;
int main ()
{
// Variable definition:
int a, b;
int c;
float f;
// actual initialization
a = 10;
b = 20;
c = a + b;
cout << c << endl ;
f = 70.0/3.0;
cout << f << endl ;
return 0;
}
Wednesday, 25 May 2016
how to print current date by using turbo c++
#off_topic but it little bit interesting ;so enjoy it!
program to print current date.
note - only for turbo c users
#include <stdio.h>
#include <conio.h>
#include <dos.h>
int main()
{
struct date d ;
getdate (& d) ;
printf ("Current system date is %d/%d/%d" ,d. da_day , d. da_mon ,d. da_year);
getch() ;
return 0;
}
How to Compile & Execute C++ Program: by using command prompt
Compile & Execute C++ Program:
Y0u can do it easily if u want to do it. So attention!
Let's look at how to save the file, compile and run the program. Please follow the steps given below:
Open a text editor and add the code as above.
Save the file as: hello.cpp
Open a command prompt and go to the directory where you saved the file.
Type 'g++ hello.cpp ' and press enter to compile your code. If there are no errors in your code the command prompt will take you to the next line and would generate a.out executable file.
Now, type ' a.out' to run your program.
You will be able to see ' Hello World ' printed on the window.
$ g++ hello.cpp
$ ./a.out
Hello World
Make sure that g++ is in your path and that you are running it in the directory containing file hello.cpp.
Thankx a lot!!
Sunday, 22 May 2016
basic syntax of c++ language
Hey everyone! today we will discuss about the syntax of c++ . So attention please!
Let us look various parts of the above program:
'-' The C++ language defines several
headers, which contain information that is
either necessary or useful to your
program. For this program, the header
<iostream> is needed.
The line using namespace std; tells the
compiler to use the std namespace.
Namespaces are a relatively recent
addition to C++.
n The next line // main() is where program
execution begins, is a single-line
comment available in C++. Single-line
comments begin with // and stop at the
end of the line. The line int main() is the main function
where program execution begins.
The next line cout « "This is my first C++
program."; causes the message "This is
my first C++ program" to be displayed on
the screen.
a The next line return 0; terminates main(
)function and causes it to return the value
0 to the calling process.
Thankx for your attention!
Let us look various parts of the above program:
'-' The C++ language defines several
headers, which contain information that is
either necessary or useful to your
program. For this program, the header
<iostream> is needed.
The line using namespace std; tells the
compiler to use the std namespace.
Namespaces are a relatively recent
addition to C++.
n The next line // main() is where program
execution begins, is a single-line
comment available in C++. Single-line
comments begin with // and stop at the
end of the line. The line int main() is the main function
where program execution begins.
The next line cout « "This is my first C++
program."; causes the message "This is
my first C++ program" to be displayed on
the screen.
a The next line return 0; terminates main(
)function and causes it to return the value
0 to the calling process.
Thankx for your attention!
how to install and learn Dev-C++
This site will be provide all instructions to learn all about programming languages ,first of all we will start from c++.
how to download c++ language, for this you just go to that link,
dev-c++ https://sourceforge.net/projects/orwelldevcpp/
Now how to install ,
1-click setup,and then click ok,i agree, and install,at the click finish.
how to download c++ language, for this you just go to that link,
dev-c++ https://sourceforge.net/projects/orwelldevcpp/
Now how to install ,
1-click setup,and then click ok,i agree, and install,at the click finish.
i think, its very helpful for beginners ,what is next , for this you just wait a next post.thanks for your attentions.
Subscribe to:
Posts (Atom)