Sunday, 25 July 2021

Use of \t in C++ with an example.

 Use of \t in C++

'\t' is a horizontal tab . It is used for giving tab space horizontally in your output

For example, 

Write a C++ program to display the following-

Name          Marks

Raj            76.5

Geeta          85.5

Simmy       93.5


Source code:

#include<iostream.h>

#include<conio.h>

void main()

{       clrscr();

         cout<<"Name\t\tMarks"<<endl;

         cout<<"Raj\t\t76.5"<<endl;

         cout<<"Geeta\t\t85.5"<<endl;

         cout<<"Simmy\t\t93.5"<<endl;

        getch();

}

Output:

Output

 

 

 

 

 

 

 

 

 

 

 

Saturday, 24 July 2021

Program to display the output using endl , clrscr() and getch() in C++

 2) Write a C++ program to display the following using endl-

Program=2

Logic=6

Documentation=2

Source code:

#include<iostream.h>

#include<conio.h>

void main()

{        

 clrscr();

cout<<"Program=2"<<endl;

cout<<"Logic=6"<<endl;

cout<<"Documentation=2"<<endl;

 

getch();

}

Output:

Output2



Note:

clrscr() and getch() both are predefined function in "conio. h" (console input output header file).
If you don’t use it in your program you wont get any error, it has some effect on the display of the output.

clrscr() - It can be expanded as clear screen and so is its purpose- to empty the buffer(memory) containing the output of previously executed programs.

getch() - It is used to make program wait for the user's input before it returns to the editing window after successful compilation and output.









Print "Hello Binod" in C++ ! Turbo C++ vs Online C++ compiler.

1) Program to print "Hello Binod" in C++.

In turbo C++,

Source Code:

#include<iostream.h>
void main()
{
         cout << "Hello Binod" ;

}


Output:

Output1

Note:

  • If you want to be a programmer, prefer use of turbo C++ compiler or visual studio or dev C++.
  • I prefer turbo C++ for compiling.
  • Minimize the use of online compiler as format of source code changes in online compiler. For example, in online C++ compiler, the source code changes for the program we have done.

#include <iostream>
int main()
{
     std::cout<<"Hello Binod";

     return 0;

}





Program to find and display area, circumference and diameter of a circle in C++.

Write a C++ program to find and display area, circumference and diameter of a circle.  Source code: #include<iostream.h> #include<c...