static extern storage classes examples in c
static storage class specifier static variables have a property of preserving their value even after they are out of their scope. This kind of variables is initialized only once and exist until the termination of the program. Their scope is local to the function to which they were defined. Global static variables can be accessed […]
storage classes examples in c
register storage class specifier This storage class declares register variables which have the same functionality as that of the auto variables. The only difference is that the compiler tries to store these variables in the register of the microprocessor if a free register memory is available. This makes the use of register variables to be […]
void pointer, NULL and Wild pointers
Wild pointers A pointer which has not initialized to anything (not even NULL) is known as a wild pointer. The pointer may be initialized to a non-NULL garbage value that may not be a valid address. int main() { int a; int*ptr; //wild pointer or bad pointer return 0; } NULL pointer A NULL pointer […]
c pointers example programs
Pointers in C language is a variable that stores/points the address of another variable. The pointer variable might be belonging to any of the data types such as int, float, char, double, short, etc. c pointers example #include <stdio.h> int main() { int i; int*ptr; ptr=&i; i=10; printf(“\n%p %p”,&i,ptr); //printf(“\n%x %x”,&i,ptr); printf(“\n%d %d”,i,*ptr); *ptr=20; //i=20; printf(“\n%u […]
c program to print digits in words
c program to print digits in words Following c program illustrate how to print digits into words. The code will take an input value of from the user and it prints each digit into correspond word format. For example, if “1234” is given as input, the output should be “one two three four”. #include <stdio.h> […]
pascal triangle c program
Pascal triangle C program C program to print Pascal triangle which you might have studied while studying Binomial Theorem in Mathematics. It takes an input value from the user i.e. number of rows and prints following patterns [quote] Rows you want to input: 5 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 [/quote] #include <stdio.h> int main() { int r,n,i,k,s; printf(“\nRows you […]
prime numbers program in c
prime numbers program in c The following code prints prime numbers using c programming language. the number is prime if it is divisible only by one and itself. Remember two is the only even and the smallest prime number. First, few prime numbers are 2, 3, 5, 7, 11, 13, 17 #include <stdio.h> int main() […]
perfect number program in c
perfect number program in c This program takes an input value from the user and checks a number is a perfect number or not. A perfect number is a positive number which is equal to the sum of all its divisors excluding itself. For example: 28 is a perfect number as 1 + 2 + 4 + 7 + 14 = […]
advance pattern programs in c
Advance pattern programs in c These programs print various patterns of numbers, stars, and spaces. These codes illustrate how to create various patterns using c program. The C programs involve the usage of multiple nesting while loops. Example#1 #include <stdio.h> int main() { int i,n,s,dn; printf(“Enter a value: “); scanf(“%d”,&n); i=1; while(i<=n) // Loop to […]
basic pattern programs in c
Basic pattern programs in c These programs print various patterns of numbers and stars. These codes illustrate how to create various patterns using c program. The C programs involve usage of nesting while loops (a while loop inside a while loop). A pattern of numbers or star or characters is a way of arranging these […]