How to inverse any number in C#

using System;
namespace ConsoleApplication2
{
    class reverse
    {
        static void Main(string[] args)
        {
            int a,b,reverse=0;
            Console.WriteLine("enter the number you want too reverse ");
            a = Int32.Parse(Console.ReadLine());
            while (a != 0)
            {

                b = a % 10;
                reverse = reverse * 10 + b;
                a /= 10;
              }

            Console.WriteLine("your reversed number is ="+ reverse );
            Console.ReadLine();
        } 
}
       }







Continue Reading

Factorial program How to use static function in C#

using System;
namespace static_factorial
{
    class Program
    {
      

        static void factorial()
        {
            {
                int num1;
                int fact = 1;
                Console.WriteLine("enter your number");
                num1 = Convert.ToInt32(Console.ReadLine());
                for (int i = 1; i < num1; i++)
                {
                    fact =fact*i;
                 
                }
                    Console.WriteLine("your ans is "+ fact);

                   }
          
        }


        static void Main(string[] args)
        {
            Console.WriteLine("here is your static code");
            Program.factorial();

            Console.ReadLine();
        }
    }
}

Continue Reading

How To Write A Simple Code IN C#

using System;

public class Book
{
    public string Title;
    public string Author;
    public short YearPublished;
    public int NumberOfPages;
    public char CoverType;
}

public class Exercise
{
    static void Main()
    {
        var First = new Book();

        First.Title = " Turbo C ";
        First.Author = "Robert Lafore";
        First.YearPublished = 1996;
        First.NumberOfPages = 872;
        First.CoverType = 'H';
        Console.WriteLine("Book Characteristics");

        Console.Write("Title:  ");
        Console.WriteLine(First.Title);
        Console.Write("Author: ");
        Console.WriteLine(First.Author);
        Console.Write("Year:   ");
        Console.WriteLine(First.YearPublished);
        Console.Write("Pages:  ");
        Console.WriteLine(First.NumberOfPages);
        Console.Write("Cover:  ");
        Console.WriteLine(First.CoverType);
        Console.ReadKey();  
 }

}
Continue Reading

Vowels counts In C#

using System;

namespace VOWELS_count
{
    class vowels
    {
        string name;
        public int check = 0;
       public  string  user_input()
        {


            Console.WriteLine("ENTER YOUR NAME");
            name = Console.ReadLine();
        return name;
        }
         public int  check_v()
         {
            foreach(char vowel in name)
            {
            if (vowel == 'a' || vowel == 'A' || vowel=='e' || vowel=='E' ||
                vowel == 'i'|| vowel == 'I' || vowel== 'o' || vowel=='O' ||
                vowel == 'u' || vowel =='U')
           
            {
         check++;
            }
            }
             return check;
         }

        static void Main(string[] args)
        {
            vowels a = new vowels();

            Console.WriteLine("Here is your vowels code");
            string m;
            int b;
            m = a.user_input();
            b = a.check_v();

            Console.WriteLine("vowels present :{0}",b);
            Console.ReadKey();
        }
    }
}






Continue Reading

Passing Structure Into A Function

#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<string>
using namespace std;

struct student
{
    string name;
    int rollno;
    float GPA;
};

void DisplayRec(struct student s);

void main()
{
        struct student s;
        
        cout<<" \n Enter name of student  : ";
        cin>>s.name;
        cout<<" \n Enter rollno of student : ";
        cin>>s.rollno;
        cout<<" \n Enter GPA of student  : ";
        cin>>s.GPA;
        DisplayRec(s);
        getch();
}

void DisplayRec(struct student st)
{

   
    cout<<" \n  name of student  : "<<st.name;
       
    cout<<" \n  rollno of student : "<<st.rollno;
       
    cout<<" \n  GPA of student  : "<<st.GPA;
       



}
Continue Reading

Structure Of Array

#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<string>
using namespace std;

struct student
{
    string name;
    int rollno;
    float GPA;
};

void main()
{
struct student s[3];
   
    for(int i=0;i<3;i++)// record input
    {
       
        cout<<" \n\n Record of student number : "<<i+1;
       
        cout<<" \n Enter name of student number : ";
        cin>>s[i].name;
        cout<<" \n Enter rollno of student number : ";
        cin>>s[i].rollno;
        cout<<" \n Enter GPA of student number : ";
        cin>>s[i].GPA;
    }

    for(int i=0;i<3;i++)// record output
    {
        cout<<" \n\n Record of student number : "<<i+1;

        cout<<" \n\n name of student number : "<<s[i].name;
        cout<<" \n rollno of student number : "<<s[i].rollno;
        cout<<" \n GPA of student number : "<<s[i].GPA;

    }


    getch();
}











Continue Reading

Program of String And subtring With Replacing Srting

#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<string>
using namespace std;

void main()
{
    string word="I m afraid programing will kill me some day";
    int choice;
    cout<<"\n Press 1 for Find subString Position 2 for Replace Position ";
    cin>>choice;
    if(choice==1)
    {

    string substring;
    cout<<"\n Enter the sub string to find its position  :  ";
    cin>>substring;
    int position=word.find(substring);
    cout<<"\n Position is : "<<position;
   
    }
    if(choice==2)
    {
   
        int strt,end;
        string replacestring;
        cout<<"\n Enter the start position of string";
        cin>>strt;
        cout<<"\n Enter the End position of string from strt";
        cin>>end;
        cout<<"\n Enter the Substring that you want to insert";
        cin>>replacestring;
        word.replace(strt,end,replacestring);
        cout<<" (The New string is) : "<<word;
       
    }
    getch();
}
Continue Reading

OOPS (Object & Classes)

CODE

#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
class human
{
public:
     string name, fullname,gender;
     string roll,age;
     string GPA,height;
    
     void nature()
     {
           cout<<"He is a nice guy. \n";
     }
     void attitude()
     {
           cout<<"He has a positive attitude. \n";
     }
     void talk()
     {
           cout<<"He talks polietly. \n";
     }
     void intel()
     {
           cout<<"He is an intelligent guy. \n";
     }
     void sports()
     {
           cout<<"He is good in sports. \n";
     }
};
void main()
{
     human person;
    
     cout<<"Name :"<<person.name<<endl;
     cin>>person.name;   
     cout<<"Full name :"<<person.fullname<<endl;
     cin>>person.fullname;
     cout<<"Gender :"<<person.gender<<endl;
     cin>>person.gender;
     cout<<"Roll no :"<<person.roll<<endl;
     cin>>person.roll;
     cout<<"Age :"<<person.age<<endl;
     cin>>person.age;
     cout<<"GPA :"<<person.GPA<<endl;
     cin>>person.GPA;
     cout<<"Height :"<<person.height<<endl;
     cin>>person.height;
     cout<<"~~~~~Alex Behaviour's~~~~~\n ";
     person.nature();
     person.attitude();
     person.talk();
     person.intel();
     person.sports();
     getch();

}
Continue Reading

OBJECT&CLASSES(MOBILE INFORMATION)

CODE:

#include<iostream>
#include<string>
#include<conio.h>

using namespace std;

class mobile{

public:

       float price;
       float dimension;
       float weight;
       string network,color;
       void display();
       void camera_front();
       void camera_back();
       void sound();
       void bluetooth();
       void messaaging();



};
void mobile::display()
{

       cout<<"QHD Display\n";
}
void mobile::camera_front()
{
       cout<<"8 meagapixel\n";
}
void mobile::camera_back()
{
       cout<<"12 meagapixle\n";
}
void mobile::sound()
{
       cout<<"Organic Sound\n";
}

void mobile::bluetooth()
{
       cout<<"250 meter range \n";
}
void mobile::messaaging()
{
       cout<<"SMS(threaded view), MMS, Email, Push Mail, IM\n";
}

void main()
{
       mobile samsung;
       cout<<"Enter the price of your mobile\n";
       cin>>samsung.price;
       cout<<"Enter the dimension of your mobile\n";
       cin>>samsung.dimension;
       cout<<"Enter the weight of your mobile\n";
       cin>>samsung.weight;
       cout<<"Enter the netwrok mode of your mobile\n";
       getline(cin,samsung.network);
       cout<<"Enter the color of your mobile\n";
       getline(cin,samsung.color);

       cout<<"\n\n********Mobile Details*********\n\n";
       cout<<samsung.price<<"\n";
       cout<<samsung.dimension<<"\n";
       cout<<samsung.weight<<"\n";
       cout<<samsung.network<<"\n";
       cout<<samsung.color<<"\n";
      
       cout<<"Display:\n";
    samsung.display();
       cout<<"Front camera:\n";
       samsung.camera_front();
       cout<<"Back camer:\n";
       samsung.camera_back();
       cout<<"Sound: \n";
       samsung.sound();
       cout<<"Bluetooth:\n";
   samsung.bluetooth();
   cout<<"Message Type:\n";
       samsung.messaaging();


getch();                              
}

Continue Reading