Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Program
- {
- public static void Main()
- {
- int product = 1; //product must start at '1' because '1' is the neutral element in a product of 'n' numbers
- string inputData;
- do{
- inputData = Console.ReadLine(); //I read one number input as a string for each of the do..while passes
- if( inputData != "x" ){ //if input date is not the string "x", then...
- //...we update the product variable with the product of itself and the current inputed number
- product = product * Convert.ToInt32(inputData);//I update the total product with the current number recieved from the user
- }
- }while( inputData != "x" );//while the input data is diferent than "x"
- Console.WriteLine("Product is: " + product );//after calculating the product, we write the result in the output
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement