Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


write a programming using for loop in c++ to generate diamond
trangel?



write a programming using for loop in c++ to generate diamond trangel?..

Answer / binoy

C++ program to print a diamond inside a box using asterisks.


#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int i=0,j=0,num;
clrscr();
cout<<"Enter limit\n";
cin>>num;
cout<<endl;
for(i=-(num+2);i<=num+2;i++)
{
for(j=-(num+2);j<=num+2;j++)
{
if(abs(i)+abs(j)<=num||j==-(num+2)
||j==(num+2)||i==-(num+2)||i==(num+2))
{
cout<<"*";
}
else
{
cout<<" ";
}
}
cout<<endl;
}
getch();
}


Another solution for the same question :

http://programscpp.blogspot.in/2012/08/program-to-print-diamond-in-box-2.html

Is This Answer Correct ?    6 Yes 2 No

Post New Answer

More C++ General Interview Questions

Can we make any program in c++ without using any header file and what is the shortest program in c++.

0 Answers   MCN Solutions,


What is dev c++ used for?

0 Answers  


Differentiate between a copy constructor and an overloaded assignment operator.

0 Answers  


Write some differences between an external iterator and an internal iterator?

0 Answers  


Which is better c++ or java?

0 Answers  


WHAT IS THE ABREVATION OF FORTRAN?

4 Answers  


Which software is used for c++ programming?

0 Answers  


How do I run c++?

0 Answers  


What is the use of cmath in c++?

0 Answers  


What is boyce codd normal form in c++?

0 Answers  


Write a corrected statement in c++ so that the statement will work properly. x + y=z;

2 Answers  


What gives the current position of the put pointer?

0 Answers  


Categories