0% found this document useful (0 votes)
6 views2 pages

Tugas Algoritma

The document contains two C# console applications. The first application checks if a given number is positive or negative, while the second checks if a number is divisible by 3, 5, or both. Each program prompts the user for input and displays the result based on the conditions specified.

Uploaded by

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

Tugas Algoritma

The document contains two C# console applications. The first application checks if a given number is positive or negative, while the second checks if a number is divisible by 3, 5, or both. Each program prompts the user for input and displays the result based on the conditions specified.

Uploaded by

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

1.

bilangan positif atau negatif

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
int i;
Console.Write( "================================\n");
Console.Write( "| nim : 1112100890 |\n");
Console.Write( "| nama : dony prastiawan |\n");
Console.Write( "================================\n\n\n");

Console.Write("masukkan nilai yang dicek = ");


i = Convert.ToInt16(Console.ReadLine());
if (i > 0)
{
Console.WriteLine("angka tersebut positif");
}
else
{
Console.WriteLine("angka tersebut negatif");
}
}
}
}

===================================================================

2. bilangan habis dibagi 3 atau 5 atau kedua-duanya


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
int i;
Console.Write("masukkan nilai yang dicek... ");
i = Convert.ToInt16(Console.ReadLine());

if (i % 5 == 0 && i % 3 == 0)
{
Console.WriteLine("angka tersebut habis dibagi 3 dan 5");
}
else if (i % 5 == 0)
{
Console.WriteLine("angka tersebut habis dibagi 5");
}
else if (i % 3 == 0)
{
Console.WriteLine("angka tersebut habis dibagi 3");
}
else
Console.WriteLine("gak enek piliane ndooo");
}
}
}

You might also like