I want to do only the one thing in that cycle … – the IF or the ELSE .. (when its true and false ofc as you know it ..) If i have two typed students with their information and my first student in group 1 is not with an excellent grade and the second one student is with excellent grade my program prints:
1)first loop on for:it;s false so it makes the else
2)second loop on for: it’s true so it makes the if
and i have:
No information
Student with excellent grade…
I want to see only the students with excellent grade (if i use BREAK; i will stop the FOR cycle) Here is my code:
int gr;
cout<<"Enter group that you want to check: ";cin>>gr;
cout<<"Students with excellent grade in group "<<gr<<":\n";
for(i=0;i<n;i++)
{
if(m[i][2]==gr && m[i][3]>=5.500)
{
for(j=0;j<4;j++)
cout<<setprecision(8)<<m[i][j]<<"\t";
}
else
cout<<"No students with excellent grade in this group"<<endl;
}
I have the same problem here. Can i use the “bool” type and how in that code(code is based on struct):
int x;
bool no_info=false;
p: cout<<"| What personal id you want to search for: ";cin>>x;
for(int i=0;i<n;i++)
{
if(pov[i].id==x)
{
no_info=true;
cout<<pov[i].id<<endl;
cout<<pov[i].name<<endl;
cout<<pov[i].lastname<<endl;
cout<<pov[i].department<<endl;
cout<<pov[i].salary<<endl;
}
}
if(no_info){
cout<<"No information"<<endl;}
goto p;
EDITED!!!
It is hard to understand what you are trying to achieve. But I think what you want is:
This will not stop your
forloop, and will only print those students who have excellent grades. If nobody has excellent grades, the program will tell you so.