Help C# Error while in putting "else"

inusena

Elite
int num1=0, num2=0, count=0, product=0;
input num1;
input num2;
while (count < num2){
product = product + num1;
count++;
}
display product;


convert mo na lang po sa algorithm at flow chart haha
 

G I N E B R A

Forum Guru
int num1=0, num2=0, count=0, product=0;
input num1;
input num2;
while (count < num2){
product = product + num1;
count++;
}
display product;


convert mo na lang po sa algorithm at flow chart haha
Pa convert kuys. Aralin ko nlng. 1st year lang po kase ako e. Tas nung K12 humms pa kinuha ko. Kya wala po talaga ako background. Pa help po.
 

inusena

Elite
[XX='G I N E B R A, c: 411158, m: 1031988'][/XX] apat dapat yung variable mo
imagine mo muna kung paano tatakbo based sa question:

"displays the product of two number using Repeated addition"

so merong 2 numbers na input ng user
num1(A)
num2(B)

merong product
product(C)

gamit daw ng repeated addition kaya kailangan mo bilangin kung nakailang add na ba
counter(D)

----
Sample:
input num1: 10
input num2: 5
(product alam natin na 10 x 5 = 50)
pero ang gagawin ng program:

product = 0;
count = 0;

product = product + 10; // 10
count = count + 1; // 1
(count == num2) false ;

product = product + 10; // 20
count = count + 1; // 2
(count == num2) false ;

product = product + 10; // 30
count = count + 1; // 3
(count == num2) false ;

product = product + 10; // 40
count = count + 1; // 4
(count == num2) false ;

product = product + 10; // 50
count = count + 1; // 5,
(count == num2) true ; // stop na

display output
product = 50
 

G I N E B R A

Forum Guru
[XX='inusena, c: 411292, m: 588361'][/XX]
Step 1 - Start
Step 2 – int A = 0, B = 0, C= 0
Step 3- Input num
Step 4- C = C + A;
Step 5- B = B +1
Step 6 - if B == 5
Output C
Else
Go to step 3
7.End
 

inusena

Elite
Step 1 - Start
Step 2 - int A = 0, B = 0, C= 0, D = 0
Step 3 - Input A
Step 4 - Input B
Step 5 - if D < B
Step 5.1 - C = C + A
Step 5.2 - D = D + 1
Step 5.3 - Go to Step 5
Step 6 - Output C
Step 7 - End
 
Top