Logical C++ Programs Asked in Interviews | C++ / C Language Logical Programs | Simple Logical C programs | C Logical Programs with Answers | Logical C Programs
This is the simple C++ logical building program for beginners.
The purpose of this type of programming is to give an idea of logical
programming for beginners so they can learn programming in efficient
ways.
Source Code
#include<iomanip>
#include<iostream>
using namespace std;
int main(void)
{
int space=4;
char Values[7]={'1','2','3','4','5','6','7'};
for(int i=7; i>0; i--)
{
for (int j=0;j<i;j++)
{
cout<<Values[j];
cout<<" ";
}
if(i!=7)
{
cout<<setw(space);
space+=4;
}
for (int k=i;k>=0;k--)
{
cout<<Values[k];
cout<<" ";
}
cout<<endl;
}
system("pause");
return 0;
}
Output of the Program

No comments:
Post a Comment