answersLogoWhite

0


Best Answer

Only the designers Brian Kernighan and Dennis Ritchie can answer this question. But I would guess it was because of the handy notation on the drawing board to represent the concept of BEGIN and END.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

Curly braces in the C Programming language is used to

  • Enclose a function(it may user defined also) .
  • Enclose a body of a segment (may be a set of statements ) and then it can be laelled.
This answer is:
User Avatar

User Avatar

Wiki User

8y ago

The term brackets usually means square brackets [], but can also be used loosely to refer to braces {} or parentheses (). Each has a different meaning in C so it's important to use the correct terminology.

Braces {}

Braces are used to delimit compound statements and function bodies. Compound statements are simply a group of two or more simple statements that are to be treated as if they were one statement. We typically refer to compound statements as code blocks. Braces are optional for simple statements but are mandatory for all function bodies.

int f (int x, int y) {

return x + y;

}

Generally speaking, braces define a scope, thus we can use braces to nest one scope within another and thus localise names to the scopes that actually use them:

void g (void) {

int x; // use x here

{

int y;

// use both x and y here

} // y falls from scope here

// use x here

} // x falls from scope here

Parentheses ()

Parentheses are used to override operator precedence. Expressions within parenthesis are always evaluated first thus allowing programmers to give precedence to those expressions. For instance, operator precedence dictates that multiplication always comes before addition, thus 3 + 4 * 5 evaluates to 23. If we wish addition to take precedence then we must parenthesise the expression accordingly, thus (3 + 4) * 5 evaluates to 35. Parenthesis has the highest precedence of any operator.

Parentheses are also used to delimit function arguments and are mandatory even if the function has anonymous or void arguments.

void x (int);

void y ();

void z (void);

void use (void) {

x (42);

y ();

y (x);

z ();

}

Note that although y has no formal arguments, arguments of any number and type can still be passed anonymously. Such code is not valid in C++ and is best avoided (use void as explicit formal argument)

Square Brackets []

Square brackets are used to declare fixed-length arrays and to access the individual elements of an array. For that reason, square brackets are commonly referred to as the array suffix operator.

char hi[] = "hello world";

printf ("The 10th character of "%s" is '%c'\n", hi, hi[9]);

Note that arrays always use zero-based indices in C; the nth character of an array can be found at index n-1.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Lun mera..

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why you use curly braces in C programming?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you rectify braces expected error in c plus plus language?

This type of error indicates you've omitted braces where braces were expected. For instance, class declarations must be enclosed within curly braces, as must function definitions.


What is d command for squareroot in C programming?

There are no commands in C-programming, you should use function sqrt from math.h


Can you use C as OOPS?

No, it is a programming language.


What is the use of c-language?

Programming, mainly.


Where we use the c language?

In computer-programming.


Why are use c language?

For is it programming used.


What programming language does the PSP use?

c++


What is c and why you use?

C is a programming language, and it's mostly used for Systems Programming. Most kernels these days have at least some C code in them.


Does the C programming language use a virtual machine?

no


How do you use loop in C programming?

#include<stdio.h>


Use of scope resolution operator in C programming?

:: operator can not be used in C.


What programming framework does C plus plus use?

C++ doesn't use a framework; it is a general purpose, object oriented programming language derived from the C programming language. Specific implementations, such as Microsoft Visual C++, make use of frameworks.