:: پشتیبانی فنی ADSL به پارسی ::

::: ADSL - ویندوز - نرم افزار - سخت افزار - موبایل - لینوکس - آفیس - شبکه - برنامه نویسی :::

:: پشتیبانی فنی ADSL به پارسی ::

::: ADSL - ویندوز - نرم افزار - سخت افزار - موبایل - لینوکس - آفیس - شبکه - برنامه نویسی :::

:: پشتیبانی فنی ADSL به پارسی ::

تقدیم به تمام پشتیبانان ADSL که به رنج در تلاشند

*** تاسیس به سال 1389 در بلاگفا ***

بایگانی
پیوندهای روزانه
  • ۰
  • ۰

 

 

نمونه اول :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
internal class Program
{
static void Main(string[] args)
{
int[] a = new int[100];

int sum = 0 ;

int i;

for (int j = 0 ; j <= 2 ; j++)
{
Console.Write(" a[{0}] = " , j ) ;
a[j] = Convert.ToInt32(Console.ReadLine()) ;
}

for (i = 0; i <= 2; i++)
{
sum += a[i];
}
Console.WriteLine(" Sum is ={0}",sum ) ;
Console.ReadKey();


}
}
}

 

نمونه دوم :

using System;
public class Exercise3
{
public static void Main()
{
int[] a= new int[100];
int i, n, sum=0;


Console.Write("\n\nFind sum of all elements of array:\n");
Console.Write("--------------------------------------\n");

Console.Write("Input the number of elements to be stored in the array :");
n = Convert.ToInt32(Console.ReadLine());

Console.Write("Input {0} elements in the array :\n",n);
for(i=0;i {
Console.Write("element - {0} : ",i);
a[i] = Convert.ToInt32(Console.ReadLine());
}

for(i=0; i {
sum += a[i];
}

Console.Write("Sum of all elements stored in the array is : {0}\n\n", sum);
}

  • ۹۸/۰۶/۱۷
  • amir khan