Lets say we have a simple problem of Accepting 2 Numerical variables 'X' and 'Y' and an alphabet from the user and print them on the Screen. Now in order to achieve the output we can write the program both in C as well as C++.
In C++ :
#include<iostream.h>
#include<conio.h>
void main( )
{ int x,y;
char a;
cout<<"Enter the First Number to be stored : "<<endl;
cin>>x;
cout<<"Enter the Second Number to be stored: "<<endl;
cin>>y;
cout<<"Enter the alphabet :"<<endl;
cin>>a;
cout<<"The stored data is:<<endl;
cout<<x<<","<<y<<","<<a<<endl;
getch( );
}
In above written program, the program asks the user to enter the 'First Number' and stores it in the Variable 'x'. Similarly, in the second statement, the program asks the user to enter the 'Second Number' and stores it in the Variable 'y'. Lastly, the Alphabet is stored in the Variable 'a'.
The output for the above program as seen in the output screen will be :
Enter the First Number to be stored :
4 ---------> 'Say you enter 4'.
Enter the Second Number to be stored:
7 ---------> 'Say you enter 7'.
Enter the Alphabet :
B ---------> 'Say you enter B'.
The stored data is:
4,7,B
Give this program a Try!!
Saturday, January 8, 2011
C/C++ : Basic Knowledge
C and C++ are 'middle level' programming languages as they comprise of both 'high-level' and low-level' language features.
This language is nowadays taught at school and college level to enhance one's programming skills as it is an easy to learn language. C++ and C programs can be worked on "Borland Turbo C++" or any other "C++" developing software. But i prefer Borland Turbo C++. It is easily available on internet.You can Download from this LINK .
C and C++ are more or less similar in functionality but there is a difference in programming syntax. It also differs in the inclusion of header files.
This language is nowadays taught at school and college level to enhance one's programming skills as it is an easy to learn language. C++ and C programs can be worked on "Borland Turbo C++" or any other "C++" developing software. But i prefer Borland Turbo C++. It is easily available on internet.You can Download from this LINK .
C and C++ are more or less similar in functionality but there is a difference in programming syntax. It also differs in the inclusion of header files.
Subscribe to:
Posts (Atom)