Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.

Example

Input:
1
2
88
42
99

Output:
1
2
88

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the range and numbers:");
            int n=Int32.Parse(Console.ReadLine);
            int a[n]=Int32.Parse(Console.ReadLine);
            do{
                n=0;
                Console.Write(_a[n]);
                n++;
            }while(a[n]!=42);
        }
    }
}
Posted

1 solution

No.

If you aren't sure if your app does what you want, run it! (Preferably in the debugger so you can watch what is happening.)

The question asks you to read numbers from the user and print them out again, until he enters 42. Your code doesn't do that. And if you run it, you will see what it does do.

This is a skill: it's called debugging, and the only way to get good at it is to practice. And when you do get good at it, you will find the same processes work in real life too...so it's worth getting the hang of!
 
Share this answer
 
v2
Comments
Leo Chapiro 9-Jan-15 10:53am    
Words of wisdom: +5
TheRealSteveJudge 9-Jan-15 11:02am    
Agree! 5*
TheRealSteveJudge 9-Jan-15 11:03am    
Maybe this member does not have an IDE...
OriginalGriff 9-Jan-15 11:12am    
C# without VS?
For a beginner? Nasty...
Afzaal Ahmad Zeeshan 9-Jan-15 15:46pm    
Secondly, almost every IDE I have tried supports breakpoints and debugging. Might be condition is that the user wrote the source code in Notepad and compiled it using the command line. :P

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900