Answer the question
In order to leave comments, you need to log in
Why does my attachment x not change always 1 does not work?
I have a task, you can see in the photo what needs to be solved through the x cycle and, that is, in the cycle they should increase in steps, here is the code and photo of the task
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main() {
float a =2.0;
float y;
float x=1.0;
for(;x<8; x+=0.5){
while(a<10){
a++;
}
if(a>x){
float y=pow(a,2)+x;
printf("y=%f a=%f\n x=%f \t",y,a,x);
}
else if(a==x){
float y=a*a;
printf("y=%f a=%f\n x=%f \t",y,a,x);
}
else if(a<x){
float y=(a*a)-x;
printf("y=%f a=%f\n x=%f \t",y,a,x);
}
}
}
Answer the question
In order to leave comments, you need to log in
#include "pch.h"
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main()
{
float a = 2;
float x = 1;
for (; x <= 8; x += 0.5)
{
if (a > x)
cout << a * a + x << "\n";
else if (a == x)
cout << a * a << "\n";
else
cout << a * a - x << "\n";
if (a < 10)
a++;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question