C# new
C# new
Console.WriteLine("Enter two numbers to find their product: "); * C# Program to get the Universal Time
{ if (a < b)
else if (b != 0)
else
{ return 0; } } }
* C# Program to Convert a Given Number of Days in terms of { for (int k = 5; k > i; k--)
class program { if (j == 0 || i == j)
{ int ndays, year, week, days, DAYSINWEEK=7; else { arr[i, j] = arr[i - 1, j] + arr[i - 1, j - 1]; }
1
days = (ndays % 365) % DAYSINWEEK;
11
Console.WriteLine("{0} is equivalent to {1}years, {2}weeks and
{3}days", ndays, year, week, days); 121
1331
Console.ReadLine(); }}
* C# Program to Print a BinaryTriangle
Program Explanation
In this C program, we are reading the number of days using ‘ndays’ integer variable. using System;
Convert the given number of days to a measure of time given in years, weeks and
days. For example 375 days is equal to 1 year, 1 week, and 3 days (ignore leap year). using System.Collections.Generic;
{ int[,] arr = new int[8, 8]; { public static void Main(String[] args)
{ Console.Write("0"); count--;
{ Console.Write("1"); Console.WriteLine(); }
lastInt = 1; } } count = 1;
Console.Write("\n"); }
for (k = 1; k <= number - 1; k++)
Console.ReadLine(); } } }
{ for (i = 1; i <= count; i++)
Runtime Test Cases
Console.Write(" ");
Enter the Number of Rows : 5
count++;
1
01
for (i = 1; i <= 2 * (number - k) - 1; i++)
010 Console.Write("*");
1010 Console.WriteLine(); }
10101 Console.ReadLine(); } }
* C# Program to Print the Sum of all the Multiples of 3 and 5 Enter number of rows
using System; 3
class program *
***
{ public static void Main()
*****
{ int number, i, k, count = 1;
***
Console.Write("Enter number of rows\n");
*
number = int.Parse(Console.ReadLine());
* C# Program to Display Floyd's Triangle with an Numeric Mode
using System; class Pascal
Console.ReadLine(); } } { if (j == 0 || i == j)
Runtime Test Cases { arr[i, j] = 1; }
1 else { arr[i, j] = arr[i - 1, j] + arr[i - 1, j - 1]; }
23
Console.Write(arr[i, j] + " "); }
456
Console.WriteLine(); }
7 8 9 10
Console.ReadLine(); } }
11 12 13 14 15
Runtime Test Cases
16 17 18 19 20 21
1
22 23 24 25 26 27 28
11
29 30 31 32 33 34 35 36
121
37 38 39 40 41 42 43 44 45
1331
46 47 48 49 50 51 52 53 54 55
14641
1 5 10 10 5 1
* C# Program to Display Numbers in the form of Triangle
1 6 15 20 15 6 1
using System;