Login


Lost your password?

Don't have an account ? Register ×
  
CPP All : Beginning to Program
Concept Notes and Resources
Concept Learning Code Sheets

Hello World #1235

This is traditional program we always start by simply displaying some characters on standard output device.

#include <iostream.h>
using namespace std;
int main()
{
cout << "Hello World" <<endl;
return 0;
}

Hello World (Variation for Older Compilers) #1237

This is a traditional program we always start by simply displaying some characters on standard output device. This variation works on older compilers like “Turbo C”still used in some schools.

#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
cout << "Hello World" <<endl;
getch();
}

Commenting Code #1243

Here is a simple example to show different types of comments.

/* This is a program to understand multi line commenting
This is a multi line comment which starts with front slash immediately
followed by asterisk and ends with asterisk and a front slash*/
#include <iostream>
using namespace std;
int main()
{
cout << "How are your today?" <<endl; //this is single line comment
}

Displaying Multiple String Literals #1241

This program shows how multiple strings can be shown one after the other on the standard output.

#include <iostream.h>
using namespace std;
int main()
{
cout << "My country"
<<" is"
<<" wonderful"
<<endl;
}

Hello World (Variation without global namespace) #1239

This is a traditional program we always start by simply displaying some characters on standard output device. This variation uses independent namespace with related objects.

#include <iostream.h>
int main()
{
std::cout << "Hello World" <<endl;
return 0;
}
Solved Problems

Displaying multiple String Literals #1563

Write a C++ code to display the following text “I am happy today.”

Displaying long cout chains #3060

Write a C++ code to display the following text using the same cout chain.

Finding errors – Programming basics #3159

Find the errors in the following code and explain.

Practice Problem
Quizzes

Concept Notes:2  Code Sheets:5  Solved Problems:3  Practice Problems:2  Quizzes:1
Back