0
C Programming tutorials
What is C Language?
C
is a programming language. The C language was
developed by Dennis Ritchie in 1972 at AT&T Bell Labs. It was called his newly
developed language C simply because there was a B programming language already
and the B language led to
the development of C Language. C language is based on ALGOL and B
languages.
As said
above C language is a programming
language. Programming language is any language that
computer system can understand directly or indirectly to can perform the
actions asked by the programmer as set of instructions in form of a computer
program.
C language is a high-level programming
language. In the computer world, the further a programming language is from the
computer architecture, the higher the language's level. You can imagine that
the lowest-level languages are machine languages that computers understand
directly. The high-level programming languages, on the other hand, are closer
to our human languages.
A computer program written in a high-level
language, such as C, Java, or Perl, is just a text file, consisting of
English-like characters and words. We have to use some special programs, called
compilers or interpreters, to translate such a program into a machine-readable
code. That is, the text format of all instructions written in a high-level language has to be converted
into the binary format. The code obtained after the translation is called
binary code. Prior to the translation, a program in text format is called source code. The
smallest unit of the binary code is called a bit (from binary digit), which can
have a value of 0 or 1. 8 bits make up one byte, and half a byte (4 bits) is
one nibble.
What is C Language?
C
is a programming language. The C language was
developed by Dennis Ritchie in 1972 at AT&T Bell Labs. It was called his newly
developed language C simply because there was a B programming language already
and the B language led to
the development of C Language. C language is based on ALGOL and B
languages.
As said
above C language is a programming
language. Programming language is any language that
computer system can understand directly or indirectly to can perform the
actions asked by the programmer as set of instructions in form of a computer
program.
C language is a high-level programming
language. In the computer world, the further a programming language is from the
computer architecture, the higher the language's level. You can imagine that
the lowest-level languages are machine languages that computers understand
directly. The high-level programming languages, on the other hand, are closer
to our human languages.
A computer program written in a high-level
language, such as C, Java, or Perl, is just a text file, consisting of
English-like characters and words. We have to use some special programs, called
compilers or interpreters, to translate such a program into a machine-readable
code. That is, the text format of all instructions written in a high-level language has to be converted
into the binary format. The code obtained after the translation is called
binary code. Prior to the translation, a program in text format is called source code. The
smallest unit of the binary code is called a bit (from binary digit), which can
have a value of 0 or 1. 8 bits make up one byte, and half a byte (4 bits) is
one nibble.
C programming codes
- Hello world
- Print Integer
- Addition
- Odd or Even
- Add, subtract, multiply and divide
- Check vowel
- Leap year
- Add digits
- Factorial
- HCF and LCM
- Decimal to binary conversion
- ncR and nPr
- Add n numbers
- Swapping
- Reverse number
- Palindrome number
- Print Pattern
- Diamond
- Prime numbers
- Find armstrong number
- Generate armstrong number
- Fibonacci series
- Print floyd's triangle
- Print pascal triangle
- Addition using pointers
- Maximum element in array
- Minimum element in array
- Linear search
- Binary search
- Reverse array
- Insert element in array
- Delete element from array
- Merge arrays
- Bubble sort
- Insertion sort
- Selection sort
- Add matrices
- Subtract matrices
- Transpose matrix
- Multiply two matrices
- Print string
- String length
- Compare strings
- Copy string
- Concatenate strings
- Reverse string
- Find palindrome
- Delete vowels
- C substring
- Sort a string
- Remove spaces
- Change case
- Swap strings
- Character's frequency
- Anagrams
- Read file
- Copy files
- Merge two files
- List files in a directory
- Delete file
- Random numbers
- Add complex numbers
- Print date
- Get IP address
- Shutdown computer
c program examples
Example 1 - C hello world program
/* A very simple c program printing a string on screen*/
/* A very simple c program printing a string on screen*/
Output of above program:
"Hello World"
"Hello World"
Example 2 - c program to take input from user using scanf
Output:
Enter a number
5
Number entered by you is 5
Enter a number
5
Number entered by you is 5
Example 3 - using if else control instructions
Output:
x is equal to one.
x is equal to one.
Example 4 - loop example
Output:
Value is 1
Value is 2
Value is 3
Value is 1
Value is 2
Value is 3
Example 5 - c program for prime number
Example 6 - command line arguments
Above c program prints the number and all arguments which are passed to it.
Example 7 - Array program
Example 8 - function program
Example 9 - Using comments in a program
Example 10 - using structures in c programming
Example 11 - c program for Fibonacci series
Example 12 - c graphics programming
For GCC users
If you are using GCC on Linux operating system then you need to modify programs. For example consider the following program which prints first ten natural numbers
Above source code includes a header file <conio.h> and uses function getch, but this file is Borland specific so it works in turbo c compiler but not in GCC. So the code for GCC should be like
If using GCC then save the code in a file say numbers.c, to compile the program open the terminal and enter command GCC numbers.c, this will compile the program and to execute the program enter command ./a.out .
Frequently asked c programs in interview
8. Write a c program to check given string is palindrome number or not.
7. Write a c program to solve quadratic equation.
8. Write a c program to print Fibonacci series of given range.
9. Write a c program to get factorial of given number.
1. Write a c program to reverse any number.
2. Write a c program to find out sum of digit of given number.
7. Write a c program to solve quadratic equation.
8. Write a c program to print Fibonacci series of given range.
9. Write a c program to get factorial of given number.
12. Write a c program to generate multiplication table.
13. Write a c program to print ASCII value of all characters.
14. C program to print hello world without using semicolon
15. Write a c program which produces its own source code as its output
C program with numbers13. Write a c program to print ASCII value of all characters.
14. C program to print hello world without using semicolon
15. Write a c program which produces its own source code as its output
1. Write a c program to reverse any number.
2. Write a c program to find out sum of digit of given number.
10. Write a c program to find out NCR factor of given number.
11. How to convert string to int without using library functions in c
12. Program in c to print 1 to 100 without using loop
13. C program for swapping of two numbers
14. Program to find largest of n numbers in c
15. Split number into digits in c programming
16. C program to count number of digits in a number
11. How to convert string to int without using library functions in c
12. Program in c to print 1 to 100 without using loop
13. C program for swapping of two numbers
14. Program to find largest of n numbers in c
15. Split number into digits in c programming
16. C program to count number of digits in a number
L.C.M and H.C.F.
Swapping
Conversion ( Number System )
2. Write a c program to convert decimal number to octal number.
3. Write a c program to convert decimal number to hexadecimal number.
4. Write a c program to convert octal number to binary number.
3. Write a c program to convert decimal number to hexadecimal number.
4. Write a c program to convert octal number to binary number.
6. Write a c program to convert octal number to hexadecimal number.
8. Write a c program to convert hexadecimal number to octal number.
9. Write a c program to convert hexadecimal number to decimal number.
10. Write a c program to convert binary number to octal number.
9. Write a c program to convert hexadecimal number to decimal number.
10. Write a c program to convert binary number to octal number.
12. Write a c program to convert binary number to hexadecimal number.
13. C program for addition of binary numbers .
14. C program for multiplication of two binary numbers.
15. C program fractional binary conversion from decimal.
16. C program for fractional decimal to binary fraction conversion.
17. C program to convert decimal number to roman.
18. C program to convert roman number to decimal number.
19. C program to convert each digits of a number in words
20. C program to convert currency or number in word.
13. C program for addition of binary numbers .
14. C program for multiplication of two binary numbers.
15. C program fractional binary conversion from decimal.
16. C program for fractional decimal to binary fraction conversion.
17. C program to convert decimal number to roman.
18. C program to convert roman number to decimal number.
19. C program to convert each digits of a number in words
20. C program to convert currency or number in word.
Conversion ( Unit )
String
3. Write a c program to delete the all consonants from given string.
9. Write a c program to print the string from given character.
10. Write a c program to reverse a string
11. Reverse a string using recursion in c
12. String concatenation in c without using strcat
13. How to compare two strings in c without using strcmp
14. String copy without using strcpy in c
15. Convert a string to ASCII in c
10. Write a c program to reverse a string
11. Reverse a string using recursion in c
12. String concatenation in c without using strcat
13. How to compare two strings in c without using strcmp
14. String copy without using strcpy in c
15. Convert a string to ASCII in c
Matrix
5. Write a c program to find out transport of a matrix.
6. Write a c program for scalar multiplication of matrix.
7. C program to find inverse of a matrix
8. Lower triangular matrix in c
9. Upper triangular matrix in c
10. Strassen's matrix multiplication program in c
11. C program to find determinant of a matrix
6. Write a c program for scalar multiplication of matrix.
7. C program to find inverse of a matrix
8. Lower triangular matrix in c
9. Upper triangular matrix in c
10. Strassen's matrix multiplication program in c
11. C program to find determinant of a matrix
File
2. Write a c program to delete a file.
3. Write a c program to copy a file from one location to other location.
6. Write a c program which writes string in the file.
9. Write a c program which concatenate two file and write it third file.
10. Write a c program to find out size of any file.
11. Write a c program to know type of file.
12. Write a c program to know permission of any file.
13. Write a c program to know last date of modification of any file.
14. Write a c program to find size and drive of any file.
10. Write a c program to find out size of any file.
11. Write a c program to know type of file.
12. Write a c program to know permission of any file.
13. Write a c program to know last date of modification of any file.
14. Write a c program to find size and drive of any file.
Complex number
3. Write a c program for multiplication of two complex numbers.
4. Write a c program for division two complex numbers.
Series
6. Write a c program to find out the sum of given H.P.
Array
6. Write a c program for insert an element at desired position in an array.
7. C program to find largest and smallest number in an array
7. C program to find largest and smallest number in an array
Sorting
5. Write a c program for heap sort.
7. Write a c program for shell sort.
Recursion
Size of data type
Using pointer
Searching
Area and volume
2. Write a c program to find the area of any triangle.
3. Write a c program to find the area of equilateral triangle.
4. Write a c program to find the area of right angled triangle.
3. Write a c program to find the area of equilateral triangle.
4. Write a c program to find the area of right angled triangle.
6. Write a c program to find the area of trapezium.
7. Write a c program to find the area of rhombus.
8. Write a c program to find the area of parallelogram.
7. Write a c program to find the area of rhombus.
8. Write a c program to find the area of parallelogram.
9. Write a c program to find the volume and surface area of cube.
10. Write a c program to find the volume and surface area of cuboids.
11. Write a c program to find the volume and surface area of cylinder.
10. Write a c program to find the volume and surface area of cuboids.
11. Write a c program to find the volume and surface area of cylinder.
12. Write a c program to find the surface area and volume of a cone.
13. Write a c program to find the volume and surface area of sphere.
13. Write a c program to find the volume and surface area of sphere.
14. Write a c program to find the perimeter of a circle, rectangle and triangle.
C program with very large numbers
1. Write a c program to find factorial of 100 or very large numbers
2. Write a c program to multiply the two very large number (larger the long int)
3. Write a c program for division of large number (larger than long int)
4. C code for modular division of large number.
5. C code for division of large number.
6. C code for power of large numbers.
Other
1. C program for ATM transaction.
C program with very large numbers
1. Write a c program to find factorial of 100 or very large numbers
2. Write a c program to multiply the two very large number (larger the long int)
3. Write a c program for division of large number (larger than long int)
4. C code for modular division of large number.
5. C code for division of large number.
6. C code for power of large numbers.
Other
1. C program for ATM transaction.
7. Write a c program to print the all prime numbers between 1 to 300.
8. Write a c program which passes structure to function.
9. Palindrome in c without using string function
10. How to get the ASCII value of a character in c
11. C program to get last two digits of year
12. C program without main function
8. Write a c program which passes structure to function.
9. Palindrome in c without using string function
10. How to get the ASCII value of a character in c
11. C program to get last two digits of year
12. C program without main function