Wednesday, May 20, 2020

C Programming


MARWARI COLLEGE, RANCHI
(AN AUTONOMOUS UNIT OF RANCHI UNIVERSITY FROM 2009)

- Prakash Kumar, Dept. of CA
______________________________________________________________________


C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the PDP-11 computer in 1972.

Some facts about C:
·         C was invented to write an operating system called UNIX.
·         C is a successor of B language which was introduced around the early 1970s.
·         The language was formalized in 1988 by the American National Standard Institute (ANSI).
·         The UNIX OS was totally written in C.
·         Today C is the most widely used and popular System Programming Language.
·         Most of the state-of-the-art software has been implemented using C.
·         Today's most popular Linux OS and RDBMS MySQL have been written in C.

Take a NOTE:
[C is a programming language that is powerful, efficient and compact. C combines the features of high level language with element of the assembler.

C is the offspring of “Basic Combine Programming Language” called ‘B’ was developed in 1960 at “Cambridge University”  
The ‘B’ language was modified by “Dennis Ritchie” at “Bell Laboratory” in 1972. ]

A C program basically consists of the following parts:
Preprocessor Commands
Functions
Variables
Statements & Expressions
Comments

#include <stdio.h>
int main()
{
printf("Hello, World! \n");
return 0;
}

Character Set 

It is helpful to run any type of program by the ‘words’, number’, and ‘expression’.
There are four character sets in C:-
·         Letter
·         Digit
·         Special character
·         White space


Tokens in C
A C program consists of various tokens and a token is a keyword, an identifier, a constant, a string literal, or a symbol.

Semicolons
In a C program, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity.

Comments
Comments are like helping text in your C program and they are ignored by the
compiler. They start with /* and terminate with the characters */ as shown
below:
/* my first program in C */

Identifiers
A C identifier is a name used to identify a variable, function, or any other userdefined item. An identifier starts with a letter A to Z, a to z, or an underscore ‘_’ followed by zero or more letters, underscores, and digits (0 to 9).
C does not allow punctuation characters such as @, $, and % within identifiers.
C is a case-sensitive programming language. Thus, Marwari and marwari are two different identifiers in C.

Rules for Identifiers:-
  • The character must be an alphabet and underscore.
  • It must consist of only letters, digit or underscore.
  • Only 31 characters are significant.
  • It cannot use keywords.
  • It must not contain white space.
Keywords
The following list shows the reserved words in C. These reserved words may not be used as constants or variables or any other identifier names(32 keywords).
Data Types
Data types in C refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted.



VARIABLES
A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.
The name of a variable can be composed of letters, digits, and the underscore character. It must begin with either a letter or an underscore. Upper and lowercase letters are distinct because C is case-sensitive.


Lvalues and Rvalues in C
There are two kinds of expressions in C:
·         lvalue : Expressions that refer to a memory location are called "lvalue" expressions. An lvalue may appear as either the left-hand or right-hand side of an assignment.
·         rvalue : The term rvalue refers to a data value that is stored at some address in memory. An rvalue is an expression that cannot have a value assigned to it which means an rvalue may appear on the right-hand side but not on the left-hand side of an assignment.

Constants and literals
Constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals.

Character literals
Character literals are enclosed in single quotes, e.g., 'x' can be stored in a simple variable of char type.

String literals
String literals or constants are enclosed in double quotes "". A string contains characters that are similar to character literals: plain characters, escape sequences, and universal characters.
Eg: “ Marwari College”

Defining Constants
There are two simple ways in C to define constants:
Using #define preprocessor
#include<stdio.h>
#define  a 10
#define  b 20
void main()
{
     printf("Value=%d",a*b);
}

Using const keyword
#include<stdio.h>
void main()
{
    const int a;
    const int b;
    int x;
    printf("Enter the value:");
    scanf("%d",&a);
    printf("Enter the value:");
    scanf("%d",&b);
    a=a+2;//Assignment of read only variable a
    scanf("%d",&a);
    printf("Value=%d",a*b);

}

Storage class
A storage class defines the scope (visibility) and life time of variables and/or functions within a C Program.
There are following storage classes which can be used in a C Program
  • auto
  • register
  • static
  • extern
auto - auto is the default storage class for all local variables.
                int main()
          {
                    int Count;
                    auto int Month;
                    return 0;

          }
The example above defines two variables with the same storage class. auto can only be used within functions, i.e. local variables.
register -
register is used to define local variables that should be stored in a register instead of RAM. This means that the variable has a maximum size equal to the register size.
NOTE: It cannot have the unary '&' operator applied to it (as it does not have a memory location).
                int main()
          {
            register int  Miles;
             return 0;
          }
Register should only be used for variables that require quick access - such as counters.

static -
static is the default storage class for global variables. The two variables below (count and road) both have a static storage class.
          static int Count;
Static variables can be 'seen' within all functions in this source file. Static can also be defined within a function. If this is done the variable is initialized at run time but is not reinitialized when the function is called. Inside a function static variable retains its value during various calls.
NOTE : Here keyword void means function does not return anything and it does not take any parameter. You can memoriese void as nothing. static variables are initialized to 0 automatically.

extern -
extern is used to give a reference of a global variable that is visible to ALL the program files. When you use 'extern' the variable cannot be initialized as all it does is point the variable name at a storage location that has been previously defined.
When you have multiple files and you define a global variable or function which will be used in other files also, then extern will be used in another file to give reference of defined variable or function. Just for understanding extern is used to declare a global variable or function in another files.


File 1: main.c
   int count=5;

   main()
   {
     write_extern();
   }
File 2: write.c
   void write_extern(void);

   extern int count;

   void write_extern(void)
   {
     printf("count is %i    \n", count);
   }
Operator
An operator is a symbol that tells the compiler to perform specific mathematical or logical functions. C language is rich in built-in operators and provides the following types of operators:
Arithmetic Operators
Relational Operators
Logical Operators
Bitwise Operators
Assignment Operators
Misc Operators



 


Operators Precedence in C

Decision-making structures
if(boolean_expression)
{
/* statement(s) will execute if the boolean expression is true */
}


eg: To find greatest between 3 numbers
#include<stdio.h>
int main()
{
int num1,num2,num3;
printf("\n Enter number1:");
scanf("%d",&num1 );
printf("\n Enter number2:");
scanf("%d",&num2);
printf("\n Enter number3:");
scanf("%d",&num3);

if(num1>num2 && num1>num3)
{
printf("\n Num1 is the largest");
}
else
{
  if(num2>num3)
  {
    printf("\n Num2 is the largest");
  }
  else
  {
    printf("\n Num3 is the largest");
  }
}
return 0;
}

Switch Statement
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case.

Syntax
The syntax for a switch statement in C programming language is as follows:
switch(expression){
case constant-expression :
statement(s);
break;                       /* optional */
case constant-expression :
statement(s);
break;                       /* optional */
default :                                             /* Optional */
statement(s);
}

eg:
#include<stdio.h>
main()
{
char ch;
float A1,A2,x,y,r;
printf("\n1 to find Area of rectangle or 2 to find Area of circle :");
scanf("%c",&ch);
switch(ch)
{
case'1':
    printf("\n Enter the length x:");
    scanf("%f",&x);
    printf("\n Enter the breath y:");
    scanf("%f",&y);
    A1=x*y;
    printf("Area of rectangle=%f",A1);
    break;
case'2':
    printf("\n Enter the radius r:");
    scanf("%f",&r);
    A2=3.14*r*r;
    printf("Area of Circle=%f",A2);
    break;
default:
        printf("\n Wrong Choice");
}
}
The   ? :   Operator:
Conditional operator ? :  can be used to replace if...else statements. It has the following general form:
Exp1? Exp2: Exp3;
Where Exp1, Exp2, and Exp3 are expressions.

#include<stdio.h>
int main()
{

    int a,b;
    printf("\n Enter the value of a:");
    scanf("%d",&a);
    printf("\n Enter the value of b:");
    scanf("%d",&b);
    ((a>b?printf("\n A is greater"):printf("\nB is greater")));
    return 0;
}






Wednesday, April 29, 2020

Financial Accounting: Accounting Principles


MARWARI COLLEGE, RANCHI
(AN AUTONOMOUS UNIT OF RANCHI UNIVERSITY FROM 2009)

- Prakash Kumar, Dept. of CA
-External Expert: Suman Ji( Chartered Accountant)
__________________________________________________________________________________
Accounting Principles

Accounting Principles
Accounting principles are the rules of action or conduct adopted by accountants universally while recording accounting transactions. GAAP refers to the rules or guidelines adopted for recording and reporting of business transactions, in order to bring uniformity in the preparation and presentation of financial statements. These principles are classified into two categories:

1) Accounting Concepts: They are the basic an assumption within which accounting operates.

2) Accounting Conventions: These are the outcome of the accounting practices or principles being followed over a long period of time.
Features of accounting principles
(1) Accounting principles are manmade.
(2) Accounting principles are flexible in nature.
(3) Accounting principles are generally accepted.

Necessity of accounting principles
Accounting information is meaningful and useful for users if the accounting records and financial statements are prepared following generally accepted accounting information in standard forms which are understood.

Types of Accounting Principles
1) Accounting Entity or Business Entity Principle: An entity has a separate existence from its owner. According to this principle, business is treated as an entity, which is separate and distinct from its owner. Therefore, transactions are recorded and analyzed, and the financial statements are prepared from the point of view of business and not the owner. The owner is treated as a creditor (Internal liability) for his investment in the business, i.e. to the extent of capital invested by him. Interest on capital is treated as an expense like any other business expense. His private expenses are treated as drawings leading to reductions in capital.

2) Money Measurement Principle: According to this principle, only those transactions that are measured in money or can be expressed in terms of money are recorded in the books of accounts of the enterprise. Non-monetary events like death of any employee/Manager, strikes, disputes etc., are not recorded at all, even though these also affect the business operations significantly.

3) Accounting Period Principle: According to this principle, the life of an enterprise is divided into smaller periods so that its performance can be measured at regular intervals. These smaller periods are called accounting periods. Accounting period is defined as the interval of time, at the end of which the profit and loss account and the balance sheet are prepared, so that the performance is measured at regular intervals and decisions can be taken at the appropriate time. Accounting period is usually a period of one year, which may be a financial year or a calendar year.

4) Full Disclosure Principle: According to this principle, apart from legal requirements, all significant and material information related to the economic affairs of the entity should be completely disclosed in its financial statements and the accompanying notes to accounts. The financial statements should act as a means of conveying and not concealing the information. Disclosure of information will result in better understanding and the parties may be able to take sound decisions on the basis of the information provided.

5) Materiality Principle: According to this principle, only those items or information should be disclosed that have a material effect and are relevant to the users. Disclosure of all material facts is compulsory but it does not imply that even those figures which are irrelevant are to be included in the financial statements. Whether an item is material or not depends on its nature. So, an item having an insignificant effect or being irrelevant to user need not be disclosed separately, it may be merged with other item. If the knowledge about any information is likely to affect the user’s decision, it is termed as material information.

6) Prudence or Conservatism Principle: According to this principle, prospective profit should not be recorded but all prospective losses should immediately be recorded. The objective of this principle is not to overstate the profit of the enterprise in any case and this concept ensures that a realistic picture of the company is portrayed. When different equally acceptable alternative methods are available, the method having the least favorable immediate effect on profit should be adopted.

7) Cost Principle or Historical cost concept: According to this Principle, an asset is recorded in the books of accounts at its original cost comprising of the cost of acquisition and all the expenditure incurred for making the assets ready to use. This cost becomes the basis of all subsequent accounting transactions for the asset. Since the acquisition cost relates to the past, it is referred to as the Historical cost.

8) Matching Principle: According to this principle, all expenses incurred by an enterprise during an accounting period are matched with the revenues recognized during the same period. The matching principle facilitates the ascertainment of the amount of profit earned or loss incurred in a particular period by deducting the related expenses from the revenue recognized in that period. It is not relevant when the payment was made or received. This concept should be followed to have a true and fair view of the financial position of the company.

9) Dual Aspect Principle: According to this principle, every business transaction has two aspects - a debit and a credit of equal amount.
In other words, for every debit there is a credit of equal amount in one or more accounts and vice-versa. The system of recording transactions on the basis of this principle is known as “Double Entry System”.
Due to this principle, the two sides of the Balance Sheet are always equal and the following accounting equation will always hold good at any point of time.
Assets = Liabilities + Capital

Example: Ram started business with cash Rs. 1,00,000.
It increases cash in assets side and capital in liabilities- side by Rs. 1,00,000.
Assets Rs. 1,00,000 = Liabilities + Capital Rs. 1,00,000.

10) Revenue Recognition Concept: This principle is concerned with the revenue being recognised in the Income Statement of an enterprise. Revenue is the grass inflow of cash, receivables or other considerations arising in the course of ordinary activities of an enterprise from the sale of goods, rendering of services and use of enterprise resources by others yielding interests, royalties and dividends. It excludes the amount collected on behalf of third parties such as certain taxes. Revenue is recognised in the period in which it is earned irrespective of the fact whether it is received or not during that period.

11) Verifiable Objective concept: This concept holds that accounting should be free from personal bias. This means that all business transactions should be supported by business documents like cash memo, invoices, sales bills etc.

Fundamental Accounting Assumptions

1) Going Concern Assumption: This concept assumes that an enterprise has an indefinite life or existence. It is assumed that the business does not have an intention to liquidate or to scale down its operations significantly. This concept is instrumental for the company in:
1. Making a distinction between capital expenditure and revenue expenditure.
2. Classification of assets and liabilities into current and non-current.
3. Providing depreciation charged on fixed assets and appearance in the Balance Sheet at book value, without having reference to their market value.
4. It may be noted that if there are good reasons to believe that the business, or some part of it, is going to be liquidated or that it will cease to operate (say within a year or two), then the resources could be reported at their current values (or liquidation values).

2) Consistency Assumption: According to this assumption, accounting practices once selected and adopted, should be applied consistently year after year. This will ensure a meaningful study of the performance of the business for a number of years. Consistency assumption does not mean that particular practices, once adopted, cannot be changed.
The only requirement is that when a change is desirable, it should be fully disclosed in the financial statements along with its effect on income statement and Balance Sheet.
Any accounting practice may be changed if the law or Accounting standard requires so, to make the financial information more meaningful and transparent.

3) Accrual Assumption: As per Accrual assumption, all revenues and costs are recognized when they are earned or incurred. This concept applies equally to revenues and expenses.
It is immaterial, whether the cash is received or paid at the time of transaction or on a later date.

Bases of Accounting
There are two bases of ascertaining profit or loss, namely:

1) Cash basis
Under this, entries in the books of accounts are made when cash id received or paid and not when the receipt or payment becomes due.

For example, if salary Rs. 7,000 of January 2010 paid in February 2010 it would be recorded in the books of accounts only in February, 2010.

2) Accrual basis
Under this however, revenues and costs are recognized in the period in which they occur rather when they are paid. It means it record the effect of transaction is taken into book in the when they are earned rather than in the period in which cash is actually received or paid by the enterprise. It is more appropriate basis for calculation of profits as expenses are matched against revenue earned in the relation thereto.
For example, raw materials consumed are matched against the cost of goods sold for the accounting period.

Difference between accrual basis of accounting and cash basis of accounting



Basis
Accrual Basis of Accounting
Cash Basis of accounting
1) Recording of
Transactions
Both cash and credit
transactions are recorded.
Only cash transactions are
recorded.
2) Profit or Loss
Profit or Loss is ascertained correctly due to complete record of transactions.
Correct profit/loss is not
ascertained because it records
only cash transactions.
3) Distinction
between Capital
and Revenue
items
This method makes a
distinction between capital
and revenue items.
This method does not make a distinction between capital and revenue items.
4) Legal position
This basis is recognized under the companies Act
This basis is not recognized under the companies Act or any other act.




Accounting Standards (AS)
“A mode of conduct imposed on an accountant by custom, law and a professional body.” – By Kohler

Concept of Accounting Standards

Accounting standards are written statements, issued from time-to-time by institutions of accounting professionals, specifying uniform rules and practices for drawing the financial statements.

Nature of accounting standards
1) Accounting standards are guidelines which provide the framework credible financial statement can be produced.
2) According to change in business environment accounting standards are being changed or revised from time to time.
3) To bring uniformity in accounting practices and to ensure consistency and comparability is the main objective of accounting standards.
4) Where the alternative accounting practice is available, an enterprise is free to adopt. So accounting standards are flexible.
5) Accounting standards are amendatory in nature.

Objectives of Accounting Standards

1) Accounting standards are required to bring uniformity in accounting practices and policies by proposing standard treatment in preparation of financial statements.
2) To improve reliability of the financial statements: Statements prepared by using accounting standards are reliable for various users, because these standards create a sense of confidence among the users.
3) To prevent frauds and manipulation by codifying the accounting methods and practices.
4) To help Auditors: Accounting standards provide uniformity in accounting practices, so it helps auditors to audit the books of accounts.

IFRS International Financial Reporting Standards
This term refers to the financial standards issued by International Accounting Standards Board (IASB). It is the process of improving the financial reporting internationally to help the participants in the various capital markets of the world and other users.

IFRS Based Financial Statements
Following financial statements are produced under IFRS:
1) Statement of financial position: The elements of this statement are:
(a) Assets
(b) Liability
(c) Equity
2) Comprehensive Income statement: The elements of this statement are   (a) Revenue (b) Expense.
3) Statement of changes in Equity.
4) Statement of Cash flow.
5) Notes and significant accounting policies.

Objectives of IFRS
1) To develop the single set of high quality global accounting standards so users of information can make good decisions and the information can be comparable globally.

2) To promote the use of these high quality standards.
3) To fulfill the special needs of small and medium size entity by following above objectives.

Benefits of IFRS
1) Global comparison of financial statements of any companies is possible.
2) Financial statements prepared by using IFRS shall be better understood with financial statements prepared by the country specific accounting standards. So the investors can make better decision about their investments.
3) Industry can raise or invest their funds by better understanding if financial statements are there with IFRS.
4) Accountants and auditors are in a position to render their services in countries adopting IFRS.
5) By implementation of IFRS accountants and auditors can save the time and money.
6) Firm using IFRS can have better planning and execution. It will help the management to execute their plans globally.