a Sequential that decreased by 5 using a for loop [closed] - c++

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
i want to print a Sequential that decreased by 5
using a for loop
but i don't know why it doesn't print the output :(
#include<bits/stdc++.h>
using namespace std;
int main(){
for(int j=60;j<=0;j-=5){
cout<<j<<endl;
}
}
whats the wrong?!

Change it to
for(int j=60;j>=0;j-=5){
^^

Related

What am I doing wrong, it's very basic C++ but gives an error? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
the code i wrote
What am i doing wrong in here it gives me an error and its very very basic.
enter code here
# include <iostream>
using namespace std;
int main()
{
string firstone = "giraffe academy";
cout << firstone.substr(8, 3);
return 0;
}
You need to
# include <string>
that defines << for std::string

The inner loop only runs once [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I am curious as though, why when I use an array in for-loop in the given manner below, the inner loop only runs once.
Thank you for your reply.
#include<iostream>
using namespace std;
int main(){
int a[2]={0};
a[0]=5;
for(a[0];a[0]<10;a[0]+=1){
for(a[1];a[1]<10;a[1]+=1){
cout<<a[0]<<" "<<a[1]<<endl;
}
}
}
You are never resetting a[1], so once it hits 10 the first time through the inner loop, it will never execute again. Modify to for(a[1]=0;a[1]<10;a[1]+=1){

Why is there a difference in output between printf and cout? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
The code using printf and cout:
int a=0;
a=printf("Hello World");
cout<<" "<<a;
Output :
11Hello World
The code using printf:
int a=0;
a=printf("Hello World");
printf("%d ",a);
Output :
Hello World11
You must have disabled synchronization between std::cout and C API?
If it is enabled I can't reproduced it
If I disable this synchronization I reproduce observed output.
For more information read about std::ios::sync_with_stdio

Why am I not able to use Vectors in the Dev C/C++ IDE [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 12 months ago.
Improve this question
So, here I wanted to just define a vector and then print the size of the vector's present state, but the compiler in dev c/c++ gives me a compile-time error that "vector was not declared in the scope()"
I wonder if I haven't included the right header files,or something.
#include<iostream>
using namespace std;
int main()
{
vector<int> v(6); //defining the vector
cout<<"Size= "<<v.size(); //printing the present size of the vector
return 0;
}
Just include vector header.
#include <vector>

Read from file negative numbers C++ [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have to get numbers from file and some of them are negative. So, how can I do that? (C++)
Now I'm trying just this (without something special):
U1.txt file:
4 5 -1 6 -2
My code:
ifstream fd(FD);
int n1,n2,n3,n4,n5;
fd>>n1>>n2>>n3>>n4>>n5;
Your code is basically correct, except for that typo with n4 missing.
This:
ifstream fd("U1.txt");
int n1,n2,n3,n4,n5;
fd>>n1>>n2>>n3>>n4>>n5;
Will do what you expect, modulo error conditions.