Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace generate_prime_nos
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool current=false;
- int j;
- Console.WriteLine("Enter a number");
- int num=Int32.Parse(Console.ReadLine());
- Console.WriteLine("The prime numbers are: ");
- for (int i = 2; i <= num; i++)
- {
- for (j = 2; j < i; j++)
- {
- if (i % j == 0)
- {
- current = true;
- break;
- }
- }
- if (current == false)
- {
- Console.Write("{0}", j);
- }
- else
- {
- current = false;
- }
- }
- Console.ReadLine();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Reverse
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n,m;
- int sum = 0;
- int rev = 0;
- Console.WriteLine("Enter a number");
- n = Convert.ToInt32(Console.ReadLine());
- while(n>0)
- {
- m=n%10;
- sum += m;
- rev = rev *10 + m;
- n=n/10;
- }
- Console.WriteLine("The reverse of the number is:{0}",rev);
- Console.WriteLine("The sum of the digit is:{0}",sum);
- Console.ReadLine();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace vowel
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Enter any character");
- char c = Convert.ToChar(Console.ReadLine());
- {
- if(c=='a'||c=='A'||c=='e'||c=='E'||c=='i'||c=='I'||c=='o'||c=='O'||c=='u'||c=='U')
- {
- Console.WriteLine("The entered character is a vowel");
- }
- else
- Console.WriteLine("The entered character is not a vowel");
- c=Convert.ToChar(Console.ReadLine());
- {
- Console.ReadKey();
- }
- }
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace foreachloop
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] numbers = { 4, 5, 6, 1, 2, 3, -1, -2, -3, 0 };
- foreach(int i in numbers)
- {
- Console.WriteLine(i);
- Console.ReadLine();
- }
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace nestedclass1
- {
- public class outer
- {
- public outer(int num)
- {
- Number = num;
- }
- public void DisplayNumber()
- {
- Console.WriteLine("The outher class Number: " + Number);
- Console.ReadLine();
- }
- public class Inner
- {
- public void DisplayNumber(outer o)
- {
- Console.WriteLine("The Inner class Number is :" + o.Number);
- Console.ReadLine();
- }
- }
- private int Number;
- }
- public class program
- {
- static void Main(string[] args)
- {
- outer o1 = new outer(100);
- o1.DisplayNumber();
- outer.Inner i1 = new outer.Inner();
- i1.DisplayNumber(o1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement