c program to show register variable scope

Register variable scope in c language:

Before writing a c program to show register variable scope lets try to understand  register variable.

There are four types of storage classes or variable scopes seen in c programming language which are Automatic variable scope, register variable scope, Static variable scope and external variable scope .

The ‘register’ keyword is used to suggest   the compiler that an automatic local variable be stored in a processor register rather than in regular memory. By using the register keyword in the definition of an automatic variable, you ask the compiler to store that variable in a register.

c program to show register variable scope
c program to show register variable scope

write a C program to show register variable scope

write a C program to show register variable scope or WAP for showing register variable scope

#include <stdio.h>
void main()
{
int n,count;
register int i; //used for faster computation
printf(“\n enter the number \n”);
scanf(“%d”, &n);
for(i = 1; i <= n; i++)
{
if (i%2==0)
count ++;
}
printf(count);
}

Other programs:

Static variable scope
Register variable scope
External variable scope
Automatic variable scope
amicable number
Prime number
Perfect number
Palindrome number
Strong number
Find Factorial 
Biggest Number
Average of n numbers
convert decimal number to octal
decimal number to hexadecimal
decimal number to binary
simple interest
compound interest
Add sparce matrices
Add matrices
 file copying
Palindrome string
Reverse string
String length
Replace characters in string
substring or not using arrays
First occurrence of character in string
Last occurrence of character in string
Convert to uppercase
Convert to lowercase
Concatenate strings 
Compare strings
Generate Employee payslips
Count students scoring marks>50%
convert weight into grams

External Links:
https://en.wikipedia.org/wiki/C_syntax#Storage_class_specifiers

Leave a Reply

Your email address will not be published. Required fields are marked *