Posts

Showing posts from October, 2023

Writing 1st program of C#

Image
  Rules to be followed.   You need to produce high quality C# Code. Here are some rules you may follow.   1. Keep everything simple and clean             Avoid complex coding in your program if you have complex program then use your time to analysis and divide into subtasks.   2. Be consistent             Be consistent as much as possible whatever you do. This is especially important when writing your code against your coding rules-coding standards.     3. Have a coding standard             A coding standard defines how you write your code.               1. For class names use Pascal Casing             2. For Function names use Pascal Casing             3. For Properties use Pascal Casing             4. Use camel Casing for member variables, parameters, local variables             5. To distinguish between local and member variables use this keyword and don’t use   Hungarian and notations having _,m_,s_ for your local or member variables   1.      Com

Structure of C# Program

  A C# program consists of the following parts −   ·        Namespace declaration ·        A class ·        Class methods ·        Class attributes ·        A Main method ·        Statements and Expressions ·        Comments   Ex :   using System;   namespace HelloWorldApplication {    class HelloWorld {       static void Main(string[] args) {          /* my first program in C# */          Console.WriteLine("Hello World");          Console.ReadKey();       }    } }   Explanation :   ·        The first line of the program using System ; - the using keyword is used to include the System namespace in the program. A program generally has multiple using statements.   ·        The next line has the namespace declaration. A namespace is a collection of classes. The HelloWorldApplication namespace contains the class HelloWorld.   ·        The next line has a class declaration, the class HelloWorld contains the data and method defini

Structure of Java Program

Java program is having below sections.   ·        Package declaration ·        Import statements ·        Comments ·        Class definition ·        Class variables, Local variables ·        Main Method ·        Methods/Behaviors   Package declaration : A class in Java can be placed in different directories/packages based on the module they are used.   Import Statements : There can be classes written in other folders/packages of our working java project and also there are many classes written by individuals, companies, etc which can be useful in our program   Comments: The comments in Java can be used to provide information about the variable, method, class or any other statement   Class definition : A name should be given to a class in a java file. This name is used while creating an object of a class, in other classes/programs Class Variables, Local Variables: The Variables are storing the values of parameters that are required during the execution of th

Structure of C++ Program

  A C++ program is structured in a specific and particular manner. In C++, a program is divided into the following three sections:   ·        Standard Libraries Section ·        Main Function Section ·        Function Body Section   For example , let’s look at the implementation of the Hello World program   #include <iostream> using namespace std;   int main() {   cout << "Hello World!" << endl;   return 0; }     Standard libraries   #include <iostream> using namespace std;   #include is a specific preprocessor command that effectively copies and pastes the entire text of the file, specified between the angle brackets, into the source code.   The file <iostream>, which is a standard file that should come with the C++ compiler, is short for input-output streams. This command contains code for displaying and getting an   input from the user.   namespace is a prefix that is applied to all the names in

Structure of C Program

  The basic structure of a C program is divided into 6 parts which makes it easy to read, modify, document, and understand in a particular format. C program must follow the  below-mentioned outline in order to successfully compile and execute. Debugging is easier in a well-structured C program.   Sections of the C Program There are 6 basic sections responsible for the proper execution of a program. Sections are mentioned below:   1.      Documentation 2.      Preprocessor Section 3.      Definition 4.      Global Declaration 5.      Main() Function 6.      Sub Programs   Documentation : This section consists of the description of the program, the name of the program, and the creation date and time of the program. It is specified at the start of the program in the form of comments. Documentation can be represented as:   Ex :       // description, name of the program, programmer name, date, time etc.   Preprocessor Section : All the header files of the pro