Do While Loop in C

Before proceeding to do while loop in C, recap the previous lesson. We seen that in our previous lesson the body of while loop doesn’t execute even a single time. We have read, if while loop condition false then program will not execute then it will be exit. Hence we can say while loop execute zero times.

Do While Loop in C plus plus:

Just imagine, if we need to type a string at least one time. Is while loop correct way to use for this program? Answer is no, because we discussed earlier lesson while loop just execute, If condition will true, means while loop not able to do this particular task. So, For this particular type of question C introduce do while loop. What actually it does?

Do while loop in C language does execute at least one time. The syntax of do while structure is as under:

  do 

  {

      Statements;

  }

  While (Condition);

Above statement shows that, Condition will be test after execute the statement. Therefore, loop of the body is executed at least one time. Then the condition of do while loop is tested,If condition true it will execute repeatedly otherwise false case it will exit in the loop.Statements are enclosed in curly brackets. In do while loop structure While Condition will be written after the statement block.

FLOW CHART of Do While Loop

Do While Loop in C

Now you can see the infrastructure of do while loop. Do while loop is a specific loop which is execute at least one time. Lets take a simple program example to understand the loop.

#include<iostream> // Header files 
using namespace std; 
main()
{
  int digits;
  cout<<"Please type first digit: ";
  cin>>digits;
  do
  {
  	digits++;
  	cout<<digits<<'n';
  }
  while(digits<100);
}

Above mentioned example is the same example of previous lesson while loop with little bit difference, Now we used do while loop structure in the above example. Above Example explicitly describing that, statement execute at least one time. Keep remember put double quotes after the close condition of do while loop. To understand deeply do while loop, we write a simple program of guessing game as under,

#include<iostream> 
using namespace std;
main()
{
  int guess=0;
  char c;
  do
  {
  	cout<<"Please enter character b/w a-z: ";
  	cin>>c;
  // Check the guess character
  if(c=='j')
  {
  	cout<<"Congratulation your guess is Correct !!";
  }
  else{
  	guess=guess+1;
  }
}
  while(guess<=3 && c!='j');
}

In the above guessing game program, we assign two variables then run do while loop, In looping procedure we mention if structure (c==j). And finally end of the loop we write while condition and put double quotes. All do while statement enclosed in curly braces. Here is output screenshot of above guessing game program.

Do While Loop in C

Keep remember C language case-sensitive so care about lower case or uppercase alphabets, if you use small ‘j’ so don’t use capital ‘J’ because differ exist both of them. In the Next lesson, we will read about for loop Structure with new enhancement. Hope you understand this structure, if you found any error during practice, then feel free comment below. 😉

While loop in C++

While loop in C++

While loop in C language, While is also a keyword of C language so it can’t use as a variable. Actually While name express, “execution will be continued until the provided condition is true” . We used curly brackets around the statement same as if statement. In simple words we can say, we enclosed the statement in curly brackets. Here is following structure of while loop.

While (Condition)
 {
 Statement
 }

Above structure shows that , In the while condition area you may use logical operators. If your condition or logical operator condition will be true, then program will be executed repeatedly,Until the statement will false.Lets take a meaningful example to understand the whole structure of while loop.

#include<iostream> // Header files
using namespace std; 
main()
{
  int Number; // Declare variable 
  cout<<"Please enter the first digit: ";
  cin>>Number;
  while(Number<10) // While loop structure 
  {
  	Number=Number+1;   // Increment in Number 
  	cout<<Number<<'n'; 
  }
}

We clearly describe the while loop in the above example as you seen, We made the simple program above, which work is typing the digits on specific limit. Make sure that You may use (Number<=10>, with equal sign then it will showing output from,initialize the digits and end on 11 because we are using increment formula Number=Number+1. You can use increment or decrements operators like as Number++, Number- -,Above the end of the example we use “n” new line tag in C language enclosed in double quotes. <<endl and n are the new line tags in C language. 

Flow Chart of While Loop

While loop in C

We Learn While loop in C Language in next lessons we will take other loops do while loop or for loop structure for more enhancement and advance tricks. Hope you understand the while loop structure, if you have any query feel free comment below.

C If else Statement Structure

C If else Statement

Every Programming language provides structure for decision-making. C Language also provides these structures. These statements are known as C If else Statements. We divide this structure into two segments. If or Else, first we take if statement structure in C language.

if (Condition)

Statement (or group of statement)

The above statement express, if statement is true, then execute the group of statement or single statement. We can understand it from the example that Bill can become the member of  the football team if he has a height more than 6 feet. In this case the condition will be

if (Bill height is greater than 6 feet)

Bill can be a member of a team

Here is the theory of block of statement.we use curly brackets {  } to build a groups of statement. Before start a statement we put { and after write statement we put }. we enclosed the statement around two curly brackets { }. Let’s take an example to express the statement 

#include // Header files
using namespace std; 
main()
{
  int Billmarks, Jhonmarks ;
  Billmarks = 20;
  Jhonmarks = 25;
  if(Billmarks < Jhonmarks)
  {
    cout<<"Jhon achieved the Goal";
}
}

Above Example explicitly express the two students marks. And we determine between those marks and announced a winner one. You may use else statement if other condition applied. Here is different example.

#include // Header files 
using namespace std;
main()
{
  int Billmarks, Jhonmarks ;
  Billmarks = 20;
  Jhonmarks = 25;
  if(Billmarks < Jhonmarks)
  {
    cout<<"Jhon achieved the Goal";
  }
  else  // Else Statement Structure 
    {
    cout<<"Bill Marks less than Jhon";
    }
}

Above example express the else statement structure. These if else structure utilize as decision structure means, if this statement is TRUE then RUN this statement otherwise run other one else statement. 

FLOW CHART OF  if else statement

C If else Statement

Operator with if else statement

#include<iostream> // Header files 
using namespace std;
main()
{
  int a,b;
  cout<<"Enter value of a: ";
  cin>>a;
  cout<<"Enter value of b: ";
  cin>>b;
  if (a==b)
  {
  	cout<<"Both are equal";
  	cin>>a;
  }
  else 
  {
  	cout<<"Both are not equal";
  	cin>>b;
  }
}

Now Above example criteria is that we take two variables a and b & assign a specific values both of them. And next apply if else structure and inside of if condition we said if both values are equal each-other then display this string “Both are equal” otherwise execute other one else statement “Both are not equal”.Hope this article will help you, if you have any query feel free comment below.

C data types

C data types:

A variable must have a data types with it, for example it may have data types integers, character, decimal numbers.There are few C data types. These data types are reserved words of c language. The reserved word cannot be used as a variable name.Let’s take a look different C data types. C language deal with whole numbers,real numbers, and character data. The C language provide three data types.

  1. Int
  2. Short
  3. Long

Int Data types:

Int (Integers) data types is used to store whole numbers. Integers data types has a space of 4 bytes in memory. And we mentioned as a “int ” & can’t use it as a variable name.Let’s take a sample example.

#include<iostream>
using namespace std;
main()
{
// Declare variables names then assign values 
   int x;  
   int y;
   int z;
   x = 5;
   y = 4;
   z = x + y;
 
// Get Output 

cout<<"x=";
cout<< x <<'n'; // <<'n' is use for new line 
cout<<"y=";
cout<< y <<'n'; // <<'n' is use for new line
cout<<"z=x+y=";
cout<< z <<'n'; // <<'n' is use for new line
}

Keep remember <<‘n’ use for new line. You may check the above code output below and try it yourself.

C data types

 Short data types:

As we learn above integers takes four bytes in memory. Suppose think if we store small data types in C then what will we do, that’s why in C language we will use Short data types. Short has a 2 bytes and it can store numbers in range -32768 to 32767. We can take the above example just replace int to short as following.

#include<iostream>
using namespace std;
main()
{
// Declare variables names then assign values 
   short x;  
   short y;
   short z;
   x = 5;
   y = 4;
   z = x + y;
 
// Get Output 

cout<<"x=";
cout<< x <<'n';
cout<<"y=";
cout<< y <<'n';
cout<<"z=x+y=";
cout<< z <<'n';   
}

Same output similar like before we have done it. Check the screenshot below.

C data types

Long data types:

Long data types is used to store very large whole numbers which cannot be store in int. So when we deal with large whole numbers then we use long data type in our program, It look like,
long x= 300400200

Real Numbers:

C Language provide two data types to deal with real numbers. Real numbers are also known as floating point numbers. (e.g. 1.25,56.898). Two types are as following

  1. Float data type
  2. Double data type

Float data type:

Float data type is used to store real number, float data type occupies 4 bytes in memory. Lets we take an example.

#include<iostream>
using namespace std;
main()
{
// Declare variables names then assign values 
   float x;  
   float y;
   float z;
   x = 5.34;
   y = 47.787;
   z = x + y;
 
// Get Output 
 
cout<<"x=";
cout<< x <<'n';
cout<<"y=";
cout<< y <<'n';
cout<<"z=x+y=";
cout<< z <<'n';   
}

Double data type:

Double data type is used to store large real numbers because float can’t store large real numbers. Double data types size is twice of float size. Its look like,
double x = 23409.0903943

Char data type:

 As we seen earlier we looking data types to store numbers, Now if we need to store character like x,y,z etc. C Provides facility to store character data in char data type. we may assign a char value to a variables following as.

#include<iostream>
using namespace std;
main()
{
	char y;
	y='z'; // Value must be in single quotes 
	cout<<"The character value in y=" <<'n';
	cout<<y;   
}

 Output screenshot of above example character data type.

C data types

C Programming tutorials for beginners

What is Programming ?

We are representing C++ programming tutorials step by step basic to advance level. First we see a widely known definition of programming. ” A program is a precise sequence of steps to solve a particular problem. “

What Skills are needed to be a good programmer ?

  • Paying attention to detail ( Read program )
  • User interface should be friendly and understandable. 
  • You should need comment before start new code section 
  • Understand the programming facts

Lesson 1:

#include<iostream>
using namespace std;

main ()
{
  cout<<"Welcome to knowledge idea";
}

We will take this above code and understand them step by step.
#include : This is a pre processor directive. It is not a part of our program, it is an instruction that we giving to the compiler. The sign # is known as HASH and also called SHARP.
<iostream> : This is the name of library definition file for all input or output streams.

main() : main function will run first. main name is important in C.main name is run when your program is used. If you forget main function and mistype then C program will return you error.
{ } : Its a Curly brackets and also called braces. Keep remember every open braces must be matching close. Braces brackets allows to group together pieces of a program.
Cout : Cout is known as Output function in C. It takes data from your computer and send it on-screen as an output. Hence we use cout for output.
<<: This sign indicates the direction of data.
” ” : Everything which are in the double quotes is known as character strings. In C programming characters strings are written in double quotes. 

Variables:

During Programming we need to store data. So this data store in variables. Variables data are storing in memory. Memory divided into blocks and viewed as a pigeon-holes. Avoid starting variables with underscore ( _ ). In C program every variable has a Name, Size, Type, Value.

Important Links:

Download Dev C++ ( Recommended C++ Editor )
Dev C++ Homepage  

W3 total cache settings & Configuration

W3 total cache settings & Configuration

W3 total cache settings and configuration is extremely important part to improve performance on server-side  and boost your website loading speed. W3 total cache recommended by hosting companies like HostGator, Page.ly, Dream host, and trusted by numerous companies like mattcutts.com, stevesouders.com, mashable.com, css-tricks.com and hundred of others. W3 total cache increase server performance and reduce download time and providing transparent content delivery network (CDN) combination. Keep remember that, before begin this settings, you may check your website/blog speed on Google Speed insights or Pingdom tool. Note the speed before installing this plugin and check after installed. Pingdom analyses screenshot.

pingdom-result

You must check your website on Google Speed insights. We will install W3 cache step by step in our WordPress panel and configure it with ease.

Step 1:

Login >> your WordPress Goto >> Plugins section  and click on Add New.

W3 cache total setting s

Step 2:

Write W3 total cache >> then search .

W3 cache total setting s

Step 3:

Next >> Click on Install Now Link which are appear below screenshot. Keep remember choose By Frederick Townes.  

W3 cache total setting s

Step 4:

Simply Next >> Click on Activate Plugin Link.

W3 cache total setting s

Step 5:

After Installation you will get a new option under WordPress sidebar menu name Performance. In Performance Option click on General Settings.

W3 cache total settings

Step 6:

Finally you Need to import W3 total cache settings in the import/Export Section. 

W3 cache total settings

Step 7:

Download W3 total cache settings and import it simply. And finally press upload button.

W3 cache total settings

W3 cache total settings

Watch Video Tutorial Complete guidance:

Hope this article will help you. If you found any error while installation and configuration so you may discuss in comments, Your feedback is respectful for us.  

HTML 5 Tags Basic tutorial

HTML 5 Tags:

HTML 5 tags are many in numbers or figures but we discuss basics tags. HTML 5 Tags makes it easier approximately. 

HTML 5 Heading Tags:

DOCTYPE html> // Declare Document type

Knowledge idea

  // Heading tags you can use h2,h3,h4..


HTML 5 Paragraph Tags:

DOCTYPE html> // Declare Document type

Knowledge idea

  // Paragraph tags


HTML 5 Images Tags:

We use “alt” because it’s extremely important and recommended by experts. Google Crawl your images then “alt” tag working as an image title.

DOCTYPE html> // Declare Document type


// Image tags, alt tag criteria is important for SEO and recommended  
Knowledgeidea

HTML 5 Hyper Link Tags:

<html>
<body>
<a href="http://www.knowledgeidea.com" alt="">Knowledge idea</a>
</body>
<html>

HTML 5 Font Tags:

<html>
<body>
<font size="5"color="#00AFEF"face="aller display">How are you friend?</font>
</body>
<html>

Firstly We use Color code in color tag . You may use simple color name like “Red” & “Green” Above example output look like this. Color codes built efficiency in your development. Secondly we use Font Family so you can use each one which you like to use. Font size is a common thing hope you know well. 

HTML 5 Tags

HTML 5 Text Format Tags:

<html>
<body>
<p> How are you friend // Paragraph Format 
<p> <b> How are you friend </b>  // Bold Format
<p> <i> How are you friend </i>  // italic Format
<p> <em> How are you friend </em> // Point out/Headline Format
<p> <code> How are you friend </code>  // Computer Output Format
</p></html>
</body>

Here we clear some differences b/w and tags. Tag express strong important for its contents and doesn’t effect on the meaning of sentences. On the other Hand Tag express stress emphasis of its contents and does effect on the meaning of sentences. Here is the screenshot of the above example.

HTML 5 Tags Read More About HTML 5 Tags