DIGIT-ARC read-only archive · snapshot: July 23, 2026

C++

5 posts · originally from https://geek.digit.in/community/threads/c.35319/

ApoorvKhatreja
ApoorvKhatreja Original post #1
Aug 30, 2006 at 11:59 PM
ahem....... i may seem very foolish, but could somebody help me out with a c++ program?


i have to write a program which produces the following output -
*
* *
* *
* *
* *
************
(this is actually the border of an equilateral triangle....i dunno why it appears like this over here........i tried to edit it a hundered times......but its coming that way)


and i have to do this using a loop ..........
it's a school assignment and i really need help!!!


its a triangle, empty from inside, and the border has been created by asterisks (*).
mod-the-pc
Aug 31, 2006 at 12:15 AM
for(i=0;i<10;i++)
for(j=0;j<10;j++)
{
if(i==j) //The slope of the triangle
cout<<"*\n";
else if(j==0 && i!=0) //The height of the tirangle
cout<<"*";
else if (i==9) //The base of the triangle
cout<<"*";
else if(j<i)//Empty fill inside the triangle
cout<<" ";
}


I don't have a C/C++ compiler. However let me know if this works.
ApoorvKhatreja
Sep 4, 2006 at 11:47 PM
its an EQUILATERAL TRIANGLE!!!!!! not a right angled triangle!!!!!
Official Techie
Sep 5, 2006 at 6:21 AM
#include<fstream.h>
#include<conio.h>

void main()
{
ofstream filout;
filout.open("marks.dat", ios::eek:ut);
char ans = 'y';
int rollno;
float marks;

while(ans =='y'||ans =='Y')
{
cout<<"\n Enter roll no:";
cin>>rollno;
cout<<"want to enter more";
cin>>ans;
}
filout.close;
}







my problem the file marks.dat should store all the values i enter but its no doing so how can i mak eit do so it should have been doing so
S
Sep 5, 2006 at 7:09 AM
You are using cout which will output to screen. You should be sending output to filout perhaps by using put function, etc.

Arun