C Programming - Functions - Discussion

Discussion Forum : Functions - General Questions (Q.No. 2)
2.
What is the notation for following functions?
1.  int f(int a, float b)
    {
        /* Some code */
    }

2.  int f(a, b)
    int a; float b;
    {
        /* Some code */
    }
1. KR Notation
2. ANSI Notation
1. Pre ANSI C Notation
2. KR Notation
1. ANSI Notation
2. KR Notation
1. ANSI Notation
2. Pre ANSI Notation
Answer: Option
Explanation:
KR Notation means Kernighan and Ritche Notation.
Discussion:
59 comments Page 1 of 6.

Raghav said:   4 years ago
K&R C is an old de facto standard for the C programming language. It was established when the C language creators, Kernighan and Ritchie, wrote the definitive book on the language.

ANSI C is another standard that was created when C got popular enough, to establish a real standard (created by an actual standards institute) and also to improve upon the language. You might also hear this standard referred to as C89, since it was published in 1989. Newer standards such as C99 and C11 also exist today, but they are all much more similar to each other (and to C89) than to the original K&R C.

One huge reason for this is a very important change in the way functions are declared. In K&R C, for instance, if you want to write a function that takes in two arguments, one of type int and one of type double, and returns nothing, you would write;


void foo(a, b)
int a;
double b;
{
// implementation
}
Meanwhile, in any standard C89 or later, you would write

void foo(int a, double b)
{
// implementation
}

This second style is known as the function prototype.

The first style is useful and maybe interesting to know if you are reading really old code, but you should never ever use it yourself. Your compiler will likely yell at you, and even if it doesn't, functions written in the old style are not subject to the same type-checking rules as the function prototype.
(2)

Bhanu said:   1 decade ago
Ex: KR notation:
---------------------
void display(__);
main()
{
display();
}
void display()
{
}

ASCII notation:
-------------------
void display(__)
{
}
main()
{
display();

Pre-ANCI Notation:
------------------

1)Main(net, err)
int *net;
double *err;
{

}

Anjali pandey said:   1 decade ago
Please explain about this notation.

Sathish said:   1 decade ago
When a memory is allocated in functions during the function call or function definition?

Madhuri said:   1 decade ago
I didn't find any difference between KR and ANSI.

Snehal said:   1 decade ago
Explain pre-ANSI notation?

Ramesh.m said:   1 decade ago
What is kernighan and ritchie notation?

Sree said:   1 decade ago
I think Memory is allocated only during function definition.

Sujith shetty said:   1 decade ago
How structures are initialize? Explain.

Gayathri said:   1 decade ago
Can you please write an example for all the notation which is present in the option?


Post your comments here:

Your comments will be displayed after verification.