Conditional Loops and \Control Statements in C++ [Detailed] Beginners Guide



Why We Use Conditional loops and Control Statements in C++

C++

For taking more then one value at the time we used loops
loops mean complete one clock in which we give values
They Are Three Types Of loops
(1)For Loop
(2)While Loop
(3) Do While Loop
For Loop
In which We Give the value and for taking many values once time we used for loop
For Example 
for(int i=0;i<=10;i++)
Complete Example of For Loop
#include<iostream.h>
#include<conio.h>
main()
{
int a[5];
for(int i=0;i<=9;i++)
{
cout<<"Plz Enter the Numbers";
cin>>a[i];
}
getch();
}

Are you interested in Best cars

WHILE LOOP EXAMPLE


#include<iostream.h>
#include<conio.h>
main()
{
int a=0;


while(a<5)
cout<<"The number is this"<<a;
a++;
}

getch();
}

for loop c++ example program,
while loop c++ multiple conditions

,do while loop c++,
control statements in c++,
while loop c++

DO WHILE LOOP EXAMPLE
#include<iostream.h>
#include<conio.h>
main()
{
int a;
a=0;
do

{
cout<<"HELLO WORD\n";

}
while(x!=0);

getch();
}
LET,s TRY YOUR OW COMPILER
BEST OF LUCK!!!!!

Graphics Programming in Dev C++ with Examples[Ultimate Guide]

Your SEO optimized title HOW TO ADD Graphics IN TURBO C++

C++ Source

Graphics are basically the main requirement of any software bcz it become software user friendly


sample graphics program in dev c++

BY Adding Graphics The programs become Graphicaly user friendly and Every Person Easily Understand The Working Of Software

Graphics in C++ tutorials

In turboo c++ it is some difficulty to add the graphics bcz it is directly not proper work therefore First of All We open C disk then we open the turbo++ Then We Open Disk After this We Open The BGI folder Now We Copy all Files Of BGi folder And then paste all files to BIN Now Graphics Properly Link With Turboo c++ And After this you can easily work on graphics And Add Graphics To your software Or Programs
HOW TO Intialize Graphics in Turboo c++
First of All We Add The Graphics.h headrel File In the Programs
Graphics.h
Then We intialize the  Graphics Driver As
int gdriver=DETECT,gmod;
then we initialize the graphics as
initgraph(&gdriver,&gmod," ");
After this whatever you want to do  with graphics in programm you can do like as draw the line ,draw the circle ,draw the 3d bar .etc; 
After Doing Work with Graphics It is must that close the Graphics same as intialize the Graphics Now we can close graphics as 
closegraph();
SYNTAX OF GRAPHICS IN TURBOO C++
Int gdriver=DETECT,gmod;
initgraph(&gdriver,&gmod,"");

closegraph();
This is the syntax of  graphics used in turboo c++

Example of Graphics

#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<stdio.h>

void main()
{
int gdriver=DETECT,gmod;
initgraph(&gdriver,&gmod,"");
clrscr();
setcolor(4);
settextstyle(4,0,5);
 settextjustify(LEFT_TEXT,RIGHT_TEXT);
outtextxy(40,3,"Ticket Management System");
settextstyle(7,0,3);
 settextjustify(LEFT_TEXT,RIGHT_TEXT);
outtextxy(145,80,"1:-For New Passenger");
settextstyle(7,0,3);
 settextjustify(LEFT_TEXT,RIGHT_TEXT);
outtextxy(145,110,"2:-Display All Passenger");
outtextxy(145,140,"3:-Search By Ticket ID");
    outtextxy(145,170,"4:-Search ByName Passenger");
outtextxy(145,170,"4:-Delete Ticket");
outtextxy(145,200,"5:-Exit");
                 rectangle(40,65,550,300);
                closegraph();
}
Let,s Try Your Own Compiler
Best of Luck!!!!

Latest Guide -- IF Else Statements in C++ With Examples For Beginners 2019

C++ Programms

Conditional Statements

In many program's we required conditions to make the program accurate and as customer want therefore we used the condition statements 
They Are Many Conditional Statements Like As
If Statement
Else Statement
Else If Statement


if else statement c++ problems

If Statement

IF Statement is the conditional statement and it is used in program when we need to put some condition or to put some limits To any Variable 
Syntax of if statement 
If (give the condition)
{

}
if else statements c++ examples
For Example 
We write A programm In which We Take The Marks From User And Then if user Enterd Marks b/w 80 -90 then programm print the Grade A????
_________________________
In this programm we used if condional statement for  Marks Grading
we Do  simple  in this programm As mentioned below
if (marks >80&&marks<=90)
{
cout<<"The grade is A";
}
Complete Example with Implementation In C++
#include<conio.h>
#include<iostream.h>
main()
{
int marks;
cout<<"Plz Enter the marks";
cin>>marks;
if(marks>80&&marks<=90)
{
cout<<"The Grade Is A";
}
getch();

}

If else statements c++ examples

ELSE STATMENT

It is also Conditional Statement But its work opposite to if statement (Bcz If Statement not true in programm then the 2nd condition will be write in else and then 2nd case mean else statement work 
Syntax of else 
if (condition)
{
}
else
{
 }

Example of If -Else Program

We write A programm In which We Take The Marks From User And Then if user Entered Marks b/w 80 -90 then programm print the Grade A  If entered Wrong Marks Then Print Student Is Fail????
_________________________
In this programm we used if condional statement for  Marks Grading
Esle Condition for Student is fail if if condition not true then else condition run
we Do  simple  in this programm As mentioned below
if (marks >80&&marks<=90)
{
cout<<"The grade is A";
}
else
cout<<"The Student Is fail"
Complete Example with Implementation In C++
#include<conio.h>
#include<iostream.h>
main()
{
int marks;
cout<<"Plz Enter the marks";
cin>>marks;
if(marks>80&&marks<=90)
{
cout<<"The Grade Is A";
}
else
cout<<"The Student is Fail";
getch();

}
Let,s Try Your Own Compiler 
Best of Luck
                     *************************

How To Apply Different types of Validations In C++ Programms



Validation of Mobile Number


we can do the validation of mobile number by using string length comparison

In Some Software's Number validation is must bcz when users entered the Mobile Number.           It can me wrong ,it can be short and it can also lengthy ( After getting the applicant number if need to contact the person the contact address may be short number may be long 
Therefore In some software's Validation Of Contact number Is Compulsory 
It Is the key of validation of Mobile Number

   while(strlen(contact)>11||strlen(contact)<11)
complete Example of Contact No Validation
#include<conio.h>
#include<iostream.h>
main()
{
char contact [25];
cout<<"\n\tEnter The Contact Number:-";
cin>>contact;
while(!cin)
{
cin.clear();
cin.ignore();
cin>>contact;
}
while(strlen(contact)>11||strlen(contact)<11)
{
 cout<<"\n\tInvalid contact number\n\tEnetr valid number -:";
 cin>>contact;
         getch();
 }

Validation of  NIC NUMBER

For Example (issuing of Sim ) (For Job Application) ;etc
Same case here as in Contact number validation
   while(strlen(nic)>13||strlen(nic)<13)

complete Example of Nic No Validation
#include<iostream.h>
main()
{
char nic [25];
cout<<"\n\tEnter The Nic Number:-";
cin>>nic;
while(!cin)
{
cin.clear();
cin.ignore();
cin>>nic;
}
while(strlen(nic)>13||strlen(contact)<13)
{
 cout<<"\n\tInvalid  Nic number\n\tEnetr valid number -:";
 cin>>nic;
         getch();
 }

Let,s Try on your own Compiler Best of luck !!!

How to Apply Input Validation In C++ Programs [Ultimate Guide] 2019

what is Input Validation

The Process In which We put the validation in any software 
By Input Validation Mean Put the limitations in any software or programm
Why We Use Input Validation In C++
By Using Input validation our programm or software can make valueable Bcz By using Validation In Software the Software give or take the accurates values or things
For Examples 
input validation c++ integer
We Make the  Student Management System Software in which we put the name age class date of birth :etc,
Input validation mean programm accept only value or data type  which we give 
For  Example :
we Take int id then c++ programm accept only integer type :
If we give character for id then Programm Not Accept this Data

(With out input validation)
char name ;
int birth;
We entered the name: 45
we entered the birth date :Ali 
input validation c++ strings
(With Input Validation)
Int birth;
char name;
int age;
cout<<"Plz Enter the Name ";
cin>>name;
while(!cin)
{
cout<<"Plz Enter the Name";
cin>>name;
}
cout<<"Plz Enter the Age " ;
cin>>age;
if(age>1&&age<=100)
{
}
else
cout<<"Plz Enter the Age";
cin>>age;
if(age>1&&age<=100)
{
cout<<"Age correct";
}


Complete Example of Input Validation In C++
#include<conio.h>
#include<iostream.h>
 void main()
{
int id;
char name;
int age;
cout<<"Plz Enter the Id";
cin>>id;
while(!cin)
{
cout<<"Plz Enter the ID";
cin>> id;
}
cout<<"Plz Enter The name ";
cin>>name;
while(!cin)
{
cout<<"Plz Enter the Correct Name";
cin>>name;
}
cout<<"Plz Enter the Age";
cin>age;
if(age>0&&age<=100)
{
cout<<"Plz Enter The Age";
cin>>age;
}
getch();
}
(Let,s Try on Your Own Compiler)
Good Luck !!!

File Handling in c++ Programs Using Class[Latest ] Beginners Guide

What Is File Handling

The process in which we can save the entered data permanent on disk in the form of files it is known as file handling 


They are two types of files in which we can do file handling

1:- Binary files

2:- Txt files

Binary files 
In this form of file handling we can store data and  benefit is that data will be stored as unseen character which is not seen and only numeric number will be seen and extenion of binary file is .dat
Txt files
In this form of files data will be shown easily in files 
In this form we can see all characters in files 

Critically Differentiate B/w Binary Files And Text Files

In binary files data can be consist of unread characters and only numeric data will be read

In txt files all data consist of readable character In text files we can easily read data in files

Explanation

For storing the data on disk in form of file we use the headrel File 

#include<fstream.h>

for only  writing data in file

we used ofstream
For only reading data from file
we used ifstream
And For Both Read and Write data in files we used
fstream

Example of File Handling (Writing Data )

#include<iostream.h>

#include<conio.h>

#include<fstream.h>

void main ()

{

int a;

char b;

cout<<"Plz Enter the Name";

cin>>b;

cout<<"Plz Enter the Age";

cin>>a;

ofstream f;

f.open("ali.txt",ios::app|ios::ate);

f<<a;

f<<b;

getch();

}

(Try on your Compiler )

Best Of Luck