Skip to main content

Various keyword present in C programming language OR Describe Various keyword present in C programming language

 Various keyword present in C programming language OR Describe Various keyword present in C programming language


Here...Various keyword present in C programming language Explain tips to 

          help you make the new concepts, you are learning 

          as a beginner to  become a Master in any programming languages really very most important:

A keyword is a reserved word. You cannot use it as a variable name, constant 

name, etc. 

There are only 32 reserved words (keywords) in the C language.


A list of 32 keywords in the c language is given below:


1.auto 2.break 3.case 4.char 5.const 6.continue  7.default  8.do


9.double 10.else 11.enum 12.extern 13.float 14.for 15.goto 16.if


17.int 18.long 19.register     20.return  21.short        22.signed  23.sizeof  24.static


25.struct 26.switch  27.typedef    28.union   29.unsigned    30.void    31.volatile  32.while



Description of all Keywords in C


auto


The auto keyword declares automatic variables. 

For example:

auto int var1;

This statement suggests that var1 is a variable of storage class auto and type int.

Variables declared within function bodies are automatic by default. 

They are recreated each time a function is executed.

Since automatic variables are local to a function, they are also 

called local variables.


break and continue


The break statement terminates the innermost loop immediately when 

it's encountered. It's also used to terminate the switch statement.

The continue statement skips the statements after it inside the loop for the iteration.


for (i=1;i<=10;++i){

   if (i==3)

   continue;

   if (i==7)

   break;

   printf("%d ",i);



Output

1 2 4 5 6


When i is equal to 3, the continue statement comes into effect and skips 3. When i is 

equal to 7, the break statement comes into effect and terminates the for loop. 


switch, case and default


The switch and case statement is used when a block of statements 

has to be executed among many blocks. For example:

switch(expression)

{

    case '1':

    //some statements to execute when 1

    break;

    case '5':

    //some statements to execute when 5

    break;

    default:

    //some statements to execute when default;

}



char


The char keyword declares a character variable. For example:

char alphabet;

Here, alphabet is a character type variable.




const


An identifier can be declared constant by using the const keyword.

const int a = 5;



do...while


int i;

do 

{

   printf("%d ",i);

   i++;

}

while (i<10)


double and float


Keywords double and float are used for declaring 

floating type variables. For example:


float number;

double longNumber;

Here, number is a single-precision floating type variable whereas, longNumber 

is a double-precision floating type variable.


if and else


In C programming, if and else are used to make decisions.

if (i == 1)

   printf("i is 1.")

else

   printf("i is not 1.")

If the value of i is other than 1, the output will be :


i is not 1



enum


Enumeration types are declared in C programming 

using keyword enum. For example:


enum suit

{

    hearts;

    spades;

    clubs;

    diamonds;

};


Here, an enumerated variable suit is created having tags: 

hearts, spades, clubs, and diamonds.



extern


The extern keyword declares that a variable or a function 

has external linkage outside of the file it is declared.



for


There are three types of loops in C programming. The for loop is written 

in C programming using the keyword for. For example:


for (i=0; i< 9;++i){

  printf("%d ",i);

}

Output


0 1 2 3 4 5 6 7 8


goto


The goto statement is used to transfer control of 

the program to the specified label. For example:


for(i=1; i<5; ++i)

{

    if (i==10)

    goto error;

}

printf("i is not 10");

error:

    printf("Error, count cannot be 10.");

Output


Error, count cannot be 10.



int


The int keyword is used to declare integer type variables. For example:


int count;

Here, count is an integer variable.



short, long, signed and unsigned


The short, long, signed and unsigned keywords are type modifiers 

that alter the meaning of a base data type to yield a new type.


short int smallInteger;

long int bigInteger;

signed int normalInteger;

unsigned int positiveInteger;

Range of int type data types

Data types Range

short int              -32768 to 32767

long int               -2147483648 to 214743648

signed int -32768 to 32767

unsigned int 0 to 65535


return


The return keyword terminates the function and returns the value.


int func() {

    int b = 5;

    return b;

}

This function func() returns 5 to the calling function. To learn more, visit C user-defined functions.


size


The sizeof keyword evaluates the size of data (a variable or a constant).

#include <stdio.h>

int main()

{

    printf("%u bytes.",sizeof(char));

}



Output


1 byte.


register


The register keyword creates register variables which 

are much faster than normal variables.


register int var1;


static


The static keyword creates a static variable. The value of the static variables persists until the end of the program. For example:


static int var;

struct


The struct keyword is used for declaring a structure. A structure can 

hold variables of different types under a single name.


struct student{

    char name[80];

     float marks;

     int age;

}s1, s2;



typedef


The typedef keyword is used to explicitly associate a type with an identifier.


typedef float kg;

kg bear, tiger;


union

A union is used for grouping different types of variables under a single name.


union student {

    char name[80];

    float marks;

    int age;

}



void


The void keyword meaning nothing or no value.

void testFunction(int a) {

  .....

}

Here, the testFunction() function cannot return a value because its return type is void.


volatile


The volatile keyword is used for creating volatile objects. A volatile 

the object can be modified in an unspecified way by the hardware.


const volatile number


Here, a number is a volatile object.


Since the number is a constant, the program cannot change it. 

However, hardware can change it since it is a volatile object.


Conclusion-In this tutorial you will have to learn Various keyword present in the C programming language

                OR Describe Various keyword present in C programming language

                So hope you liked this tutorial. If you have any questions or suggestions related to Any programming languages, please comment below and let us know.

                Finally, if you find this post informative, then share it with your friends on Facebook, Twitter, Instagram. 


 Thank you...




Comments

Popular posts from this blog

Generate Documentation for Spring Boot API with swagger and Open API 3

 ðŸ˜‚ How to Generate Documentation for Spring Boot API project Make sure your Project having a swagger or open API 3 Dependency then only you get proper Documentation for your Service. ---------------------------------------------------------------------------- Every method or API above you have to Write Like that then only you get proper Documentation If you do everything in your Application and Run your Application and go to browse and search. . http://localhost:8080/v3/api-docs/ if you want to learn more go with this one.  Open API-3   1. For Return List of Object then you have to use this API operation  @Operation(summary = "This will fetch List of Patient Detailas base on Hospital Name") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully fetch All Patient Details from Database ", content = {  @Content(mediaType = "application/json" ,array = @ArraySchema(schema =@Schema(implementation =PatientDe...

#FibonacciNumberSeries Write a program of Fibonacci Number Series|| Fib...

Fibonacci Number Series ============================================ 0 1 1 2 3 5 8 13............. a=0; b=1; i=2; printf(a,b); while(i<=n){ c=a+b; printf(c); a=b; b=c; i++; } =========================================================================== import java.util.Scanner; class Fibonacci { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int a=0,b=1,c; System.out.print(a+" "+b); for(int i=2;i

In a new programming language how can store multiple types of data in a single variable OR is it possible how can store multiple types of data in a single variable in programming langauge

In a new programming language how can store multiple types of data in a single variable  OR is it possible how can store multiple types of data in a single variable in a programming language Here In a new programming language how can store multiple types of  data in a single variable   help you make the new  concepts, you are learning a programming  Languages really very important: Ideally Yes. If you create an Array of objects. Then it's possible to store any data type with it as an object is the base class. ArrayList can hold multiple types of data, but array doesn't. Variables Variables can be thought of as ‘containers’ for data. Each variable has to  have a unique name, so that you can refer back to it in the program. By using variables, we can refer to values that have not yet been defined.  For example, we can refer to the speed of the ball in different parts of the  game code, but calculate the ball speed later based on different input...