Skip to main content

Posts

Showing posts from July, 2016

difference between global variable and extern variable

Global variable and extern variable are almost same but only one difference that is scope of variable can be controlled by user in extern variable. Global variable A  global variable  is a variable that is defined outside of all functions and it is available to all functions. These variables are unaffected by scopes and are always visible to functions and files, which means that a global variable exists until the program ends. global variable  are variables which are declared above the main( ) function. These variables are accessible throughout the program. They can be accessed by all the functions in the program. Their default value is zero. Extern Variable It is possible to create a global variable in one file and access it from another file. In order to do this, the variable must be declared in both files, but the keyword  extern  must precede the "second" declaration. A particular extern variable can be declared many times but we can initialize at only one t

factorial of the given number

Factorial of the given number This is the program for find the factorial of the given number Now you think given number is 5. #include<stdio.h> #include<string.h> int fac(int a); int main() { int fact; fact = fac(5); printf("factorials of 5 is %d",fact); } int fac(int a) { if(a<=1) { return 1; } else { a=a*fac(a-1); return a; } }

Important C Programs

important C Programs  This is the very important C programs asked in interviews. 1. Write a program to find factorial of the given number. 2. Write a program to check whether the given number is even or odd. 3. Write a program to swap two numbers using a temporary variable. 4. Write a program to swap two numbers without using a temporary variable. Material from Interview Mantra. Subscribe to free updates via email. 5. Write a program to swap two numbers using bitwise operators. 6. Write a program to find the greatest of three numbers. 7. Write a program to find the greatest among ten numbers. 8. Write a program to check whether the given number is a prime. 9. Write a program to check whether the given number is a palindromic number. 10.Write a program to check whether the given string is a palindrome. 11.Write a program to generate the Fibonacci series. 12.Write a program to print "Hello World" without using semicolon anywhere in the code. 13.Writ