Showing posts with label logic building Program in cplusplus. Show all posts
Showing posts with label logic building Program in cplusplus. Show all posts

Wednesday, 28 January 2015

Print A with Logical Code in C++

Structure of the Problem Requirements 

This Program is substantially added to understanding of logic building and improved programming skills. The purpose of this piece of code is to learn logic building . Instead of going with hard coding just try to do it with little bit change in logic. With this logic the program will display the alphabet A.

Source Code

#include <iostream>
#include <iomanip>
using namespace std;
void display_A();
int main() {
cout<<"\t \t \t LEP Tutorials \n \n \n";
display_A();
return 0;
}
void display_A(){
int j=1;
for(int i=13;i>0;i--){
if(i==6){
j++;
cout<< setw(i-1)<<"";
for(int k=0;k<j;k++){
cout<<"*";
}
cout<<"\n";
j++;
}else{
j++;
cout<< setw(i)<<"*"<<setw(j)<<"*\n";
j++;
}
}
}

Output of the Program

Print A with Logical Code in C++