[go: up one dir, main page]

0% found this document useful (0 votes)
37 views1 page

Write A Program in C# Sharp To Read User Input Number of Values in An Array and Display It in Reverse Order

The document contains a C# program that prompts the user to input a specified number of integers into an array. It then displays the entered numbers in their original order followed by their reverse order. The program utilizes basic array handling and loops to achieve this functionality.

Uploaded by

angelica campued
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views1 page

Write A Program in C# Sharp To Read User Input Number of Values in An Array and Display It in Reverse Order

The document contains a C# program that prompts the user to input a specified number of integers into an array. It then displays the entered numbers in their original order followed by their reverse order. The program utilizes basic array handling and loops to achieve this functionality.

Uploaded by

angelica campued
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Problem

1. Write a program in C# Sharp to read user input number of values in an array


and display it in reverse order.

Source Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ReverseArray
{
class Program
{
static void Main(string[] args)
{
//1. Write a program in C# Sharp to read user input number of values in
an array and display it in reverse order.//

int[] ArrayNum = new int [100];


int x, num;

Console.Write("How many number do you want to input? ");


num = Convert.ToInt32(Console.ReadLine());

Console.Write("\nEnter a number:\n");

for (x = 0; x < num; x++)


{

Console.Write("", x);
ArrayNum[x] = Convert.ToInt32(Console.ReadLine());
}

Console.WriteLine("\nThe numbers inputted are : \n");

for (x = 0; x < num; x++)


{
Console.Write("{0} ", ArrayNum[x]);
}

Console.WriteLine("\n\nThe numbers in reverse order :\n");


for (x = num - 1; x >= 0; x--)
{
Console.Write("{0} ", ArrayNum[x]);
}
Console.ReadKey();
}
}
}

Output:

You might also like