यह आउटपुट मैं प्राप्त करने के लिए कोशिश कर रहा हूँ है:उपयोग रैंड() विभाजन तालिका में संख्या उत्पन्न करने के लिए
(बेतरतीब var1)/(बेतरतीब var2) =
उत्तर: (वर ans)
मैंने पहले ही जोड़, घटाव और गुणा किया है लेकिन मुझे विभाजन के साथ कठिनाई का सामना करना पड़ा क्योंकि मुझे विभाजन के लिए सटीक लाभांश और विभाजक की आवश्यकता है ताकि जवाब देना मुश्किल न हो।
उदाहरण:
40/5 =
उत्तर: 8
नहीं इस एक:
7/5 =
उत्तर: नाव मूल्य
int x,num,num2,ans,quo,score=0;
time_t t;
clrscr();
for(x=0;x<5;x++)
{
srand((unsigned) time(&t));
num2=rand()%10;
quo=num/num2;
if(num2==1)
{
num=rand()%9;
}
else if(num2==2)
{
num=2 + (2 * rand()) %18; //this should return a value divisible by 2(ranges 0-18)
}
else if(num2==3)
{
num=rand()% //this should return a value divisible by 3 only (ranges 0-27)
}
else if(num2==4)
{
num=rand()% //this should return a value divisible by 4 only (ranges 0-36)
}
else if(num2==5)
{
num=rand()% //this should return a value divisible by 5 only (ranges 0-45)
}
else if(num2==6)
{
num=rand()% //this should return a value divisible by 6 only (ranges 0-54)
}
else if(num2==7)
{
num=rand()% //this should return a value divisible by 7 only (ranges 0-63)
}
else if(num2==8)
{
num=rand()% //this should return a value divisible by 8 only (ranges 0-72)
}
else if(num2==9)
{
num=rand()% //this should return a value divisible by 9 only (ranges 0-81)
}
else if(num2==10)
{
num=rand()% //this should return a value divisible by 10 only (ranges 0-90)
}
else
{
}
gotoxy(30,14);
printf("\n%d/%d = ",num,num2);
printf("\nAns: ");
scanf("%d",&ans);
}
भागो यह पीछे की ओर? दिया गया x/y = z, y और z उत्पन्न करें, फिर x के लिए हल करें। – VolatileDream
हाँ, कभी-कभी थोड़ा सा सामान्य ज्ञान एक लंबा रास्ता तय कर सकता है। – dtech