Thursday, 24 August 2017

DSA traverse of array

The word "traverse" means "to go or travel across or over" . It just means you need to iterate (go through each element (an element being a portion of data the size of whatever data type the array holds)).

Algorithm To Traverse A Array:
   We are taking an array A of n elements   
      traverse(A,n)
1.Set k:=0      //Assigning value to k
2.Set i:=0
3. Repeat  4&5 while k<n:
4.print:A[i]
5.i=i+1
6.Exit

Monday, 20 February 2017

How to Write C++ code in Dev C++

There are some steps you must be taken care :
 1)In C we used "stdio.h"  as a common header file but in  C++  we used "iostream" header file .
 2)After writing header file write   using namespace std   .
 3)In C we write printf() and  scanf() but in  C++ we write cout<< and cin>> for output and taking       value respectively.
 THESE ARE THE SOME COMMON STEPS TO TAKE CARE WHILE WRITING THE C++ PROGRAM
 EXAMPLE:
       #include<iostream>
        using namespace std ;
       main()
     {
         cout<<"hello";
         int a,b,c;
         cout<<endl;    //to change the line
         cin>>a;
         cin>>b;
         c=a+b;
         cout<<"sum is :"<<c;
   }