Sunday, 6 December 2015

Diamond shape Source code example in c/c++ source code, Diamond shape code example source code, source code,

Diamond shape Source code example in c/c++ source code, Diamond shape code example source code, source code,// LCM CODE Example.cpp : Defines the entry point for the console application.


// diamond2.cpp : Defines the entry point for the console application.
// 








#include "stdafx.h"
#include <iostream.h>
int main()
{
int Max_DiamondRange = 100, MainCounter = 1;
int LoopRange = ((Max_DiamondRange - 2)/4); //For Running Upper and Lower Loop Seprate.


int StartRange = 1;
int EndRange = 0;


//Print 1st *
cout<<"Diamond Structure with "<<Max_DiamondRange<<" '*'."<<endl<<endl<<endl;
while((LoopRange+1) >= MainCounter){
cout<<" ";
MainCounter++;
}
cout<<"*"<<endl;


//Generate Upper Body of the diamond
MainCounter = 1;
while(LoopRange >= MainCounter){

StartRange = 1;
EndRange = (LoopRange - MainCounter) + 1;
while(EndRange >= StartRange){
cout<<" ";
StartRange++;
}

cout<<"*";

StartRange = 1;
EndRange = (2 * MainCounter)-1;
while(EndRange >= StartRange){
cout<<" ";
StartRange++;
}

cout<<"*"<<endl;

MainCounter++;
}

//Generate lower Body of the diamond
MainCounter = 1;
while(LoopRange >= MainCounter){

StartRange = 1;
EndRange = MainCounter;
while(EndRange >= StartRange){
cout<<" ";
StartRange++;
}

cout<<"*";

StartRange = 1;
EndRange = ((LoopRange * 2) - (MainCounter * 2)+1);
while(EndRange >= StartRange){
cout<<" ";
StartRange++;
}

cout<<"*"<<endl;

MainCounter++;
}


//Print last *
MainCounter = 1;
while((LoopRange+1) >= MainCounter){
cout<<" ";
MainCounter++;
}
cout<<"*"<<endl<<endl;



cout<<"HeHeHe !"<<endl;
return 0;
}

Diamond shape example in c/c++ source code, Diamond shapeexample source code, source code,
Diamond shape example in c/c++ source code, Diamond shapeexample source code, source code,
Diamond shape example in c/c++ source code, Diamond shapeexample source code, source code,
Diamond shape example in c/c++ source code, Diamond shapeexample source code, source code,

Dear Readers if you have any query/question feel free to ask me via comment box given below. Also Follow us on social media site and share that post with your friends. - See more at: http://onlinecomputercafe.blogspot.com/2015/12/lcm-source-code-example-in-cc-source.html#sthash.oxxMKP7j.dpuf

LCM Source code example in c/c++ source code, LCM code example source code, source code,

LCM example in c/c++ source code, LCM example source code, source code,// LCM CODE Example.cpp : Defines the entry point for the console application.












# include <iostream>
# include <string >
using namespace std;
int main()
{
         int a,b,c;
         cout<< "Enter two nos :"<<endl;
         cout<<endl;
         cout<< "Enter first no. : ";
         cin>>a;
         cout<< "Enter sec. no. : ";
         cin>>b;
         c=a*b;
         while(a!=b)
              {
                    if(a>b)
                    a=a-b;
                    else
                    b=b-a;
               }
          cout<< "HCF = " << a<<endl;
          cout<< "LCM = " << c/a<<endl;
return 0;
}

LCM example in c/c++ source code, LCM example source code, source code,
LCM example in c/c++ source code, LCM example source code, source code,
LCM example in c/c++ source code, LCM example source code, source code,
LCM example in c/c++ source code, LCM example source code, source code,

Dear Readers if you have any query/question feel free to ask me via comment box given below. Also Follow us on social media site and share that post with your friends.

LinkWithin