C++ Programming |
- Demonstrates the use of structure in C++
- Launch notepad using C++
- If - Else example
- A short string demonstration
- A Simple if Statement
Demonstrates the use of structure in C++ Posted: 20 Apr 2013 08:21 AM PDT #include <iostream> using namespace std; int main() { // Defining a structure struct PersonalData { char *FirstName; char *LastName; char *Birthday; // in the format of 12/27/1978 int PhoneNum; }; // don't forget the ending ";" // Declaring a variable of type PersonalData |
Posted: 20 Apr 2013 07:38 AM PDT #include <iostream.h> #include <windows.h> int main(void) { cout<<"Explorer will launch.\n"<<endl; /*replace with the path to your explorer.exe*/ system("h:\\windows\\explorer.exe"); return 0; } |
Posted: 20 Apr 2013 07:36 AM PDT #include <iostream.h> #include <math.h> int main() { double radius; //get user input cout<<"Please enter the radius : "; cin>>radius; //act on user input if(radius < 0.0) cout<<"Cannot have a negative radius"<<endl; else cout<<"The area of the circle is "<<3.1416 * pow(radius,2)<<endl; return 0; } |
Posted: 20 Apr 2013 07:24 AM PDT #include <iostream> #include <string> using namespace std; int main() { string str1("A"); string str2("B"); string str3("O"); string str4; str4 = str1; cout << str1 << "\n" << str3 << "\n"; str4 = str1 + str2; cout << str4 << "\n"; str4 = str1 + " to " + str3; cout << str4 << "\n"; if(str3 > str1) cout << "str3 > str1\n"; if(str3 == str1+str2) |
Posted: 20 Apr 2013 07:22 AM PDT This program illustrates a simple if statement. It reads in two integers and prints out a message on the screen according to their values. #include <iostream> using namespace std; int main() { int a, b; cout << "Enter first number: "; cin >> a; cout << "Enter second number: "; cin >> b; if(a < b) cout << "First number is less than second.\n"; return 0; } |
You are subscribed to email updates from C++ Programming To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
Post a Comment