Status
Not open for further replies.

ApoorvKhatreja

Journeyman
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 (*).
 
Last edited:

mod-the-pc

Back to School Mr. Bean !
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.
 

Official Techie

In the zone
#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
 

sakumar79

Technomancer
You are using cout which will output to screen. You should be sending output to filout perhaps by using put function, etc.

Arun
 
Status
Not open for further replies.
Top Bottom