Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/
#include <stdio.h>
int main()
{
double a,b,c=0,d=0;
while(1)
{
if(d==2)
break;
scanf("%lf", &a);
if(a>=0 && a<=10)
{
d++;
c+=a;
}
else
printf("nota invalida\n");
}
b=c/2.00;
printf("media = %.2lf\n", b);
return 0;
}
You should be use Comment in your code
ReplyDeleteThis comment has been removed by the author.
ReplyDelete#include
ReplyDeletemain()
{
float a, b, c;
scanf("%f", &a);
while(a<0 || a>10){
printf("nota invalida\n");
scanf("%f", &a);
}
scanf("%f", &b);
while(b<0 || b>10){
printf("nota invalida\n");
scanf("%f", &b);
}
c=(a+b)/2;
printf("media = %.2f\n", c);
}
#include
ReplyDeleteint main()
{
float a,b;
while(1)
{
scanf("%f",&a);
if(a<0 || a>10)
printf("nota invalida\n");
else
break;
}
while(1)
{
scanf("%f",&b);
if(b<0 || b>10)
printf("nota invalida\n");
else
break;
}
printf("media = %.2f\n",(a+b)/2);
return 0;
}
amazing way of thinking \and this source code is much esier to underestand
Delete#include
Deleteusing namespace std;
int main(){
float X,Y;
int count = 0;
while(true){
if(count == 0){
cin >> X;
if(X >= 0.0 && X <= 10.0){
count = 1;
}else{
cout<<"nota invalida"<> Y;
if(Y >= 0.0 && Y <= 10.0){
printf("media = %.2f\n",(X+Y)/2);
break;
}else{
cout<<"nota invalida"<<endl;
}
}
}
}