Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobierenF&A Diskussionen
why does this code output that there is an error because the else statement doesn't have a corresponding if statement?. How do i correct this?
#include <iostream>
using namespace std;
int main() {
int a;
for (int x =0; x<5;x++){
cin>>a;
if (a<1){
cout<<"a cannot be less than 1\n";
}
else if (a>10){
cout <<"a cannot be greater than 10\n";
}
}
else{
cout<<"code can run now"<<endl;
}
return 0;
}
3 Stimmen
8 Antworteni need c++ program does EXAMPLE: If the user entered the #’s: 999, 90,78,82,and 999
the output would be
AVERAGE = 250/3 = 83.3 AVERAGE WITH LOWEST DROPPED = 172/2 = 86.0
AVERAGE WHERE HIGHEST COUNTS TWICE =340/4 = 85.0
NOTE: Validate the input as being a plausible test score and require the user to reenter when not plausible.
1 Stimme
7 AntwortenWhy not normal I/O
0 Stimmen
1 AntwortI'm trying to calculate the decimal places of pi with Ramanujan's formula. but with this code I'm getting the same output for all values of n, which it shouldn't.
from math import sqrt, factorial as f
sum=0
n=0
k=(2*sqrt(2)/9801)
while n<=100000:
sum=sum+((f(4*n))*(1103+(26390*n)))/(((f(n))**4)*(396**(4*n)))
y=1/(k*sum)
print('%.60f' % y)
n=n+1
where am I doing wrong?
2 Stimmen
4 AntwortenContinuous problem
1 Stimme
1 AntwortWhat does the 'cout' operator do?
2 Stimmen
2 AntwortenPlease explain.
0 Stimmen
2 AntwortenWhat is the code for this?
1 Stimme
1 AntwortI need help with the output?
1 Stimme
1 AntwortWorking on Files
0 Stimmen
2 AntwortenHeute heiß
Access deny problem
2 Votes
3 consecutive words
0 Votes
BOTSS
0 Votes
c++ help
0 Votes
A small question
0 Votes
Help
0 Votes
How to use ai ?
0 Votes
What's wrong with my code?
0 Votes