Вы находитесь на странице: 1из 10

List of C programming Looping (while, do while, for) programs.

1. C Program to print tables from numbers 1 to 20.


2. C Program to check entered number is ZERO, POSITIVE or NEGATIVE until user
does not want to quit.
3. C Program to find factorial of a number.
4. C Program to find sum of first N natural number, N must be taken by the user.
5. C program to print all prime numbers from 1 to N.
6. C program to print all even and odd numbers from 1 to N.
7. C program to print all Armstrong numbers from 1 to N.
8. C program to print square, cube and square root of all numbers from 1 to N.
9. C program to print all leap years from 1 to N.
10. C program to print all upper case and lower case alphabets.

List of C programming Basic Input, Output, if else, Ternary Operator


based Programs.
1. Program to print "Hello World!" / First C program.
2. Program to find sum and average of two numbers.
3. Program to calculate simple interest.
4. Program to check whether number is EVEN or ODD.
5. Program to find largest number among three numbers.
6. Program to find gross salary of an employee.
7. Program to convert temperature from Fahrenheit to Celsius and vice versa.
8. Program to calculate X^N (X to the power of N) using pow function.
9. Program to find the difference of two numbers.
10. Program to print size of variables using sizeof() operator.
11. Program to demonstrate examples of escape sequences.
12. Program to find area and perimeter of circle.
13. Program to find area of a rectangle.
14. Program to calculate HCF of two numbers.
15. Program to multiply two numbers using plus operator.
16. Program to demonstrate example of global and local scope.
17. Program to demonstrate example of floor and ceil functions.

List of C programming switch case Examples/Programs

1.
2.
3.
4.
5.

C
C
C
C
C

program
program
program
program
program

to
to
to
to
to

read weekday number and print weekday name using switch.


read gender (M/F) and print corresponding gender using switch.
check whether a character is VOWEL or CONSONANT using switch.
design calculator with basic operations using switch.
check whether number is EVEN or ODD using switch.

1) C program to print string one by one characters using loop.


2) C program to count upper case, lower case and special characters in a
string.
3) C program to convert string in upper case and lower case.
4) C program to toggle case of all characters of string.

5) C program to reverse string in same variable, without


using another string variable to reverse.
6) C program to find occurrence of a character in the string.
7) C program to replace all vowels with star (*) and consonants with hash
(#) of string.

List of Number System Conversion Programs in C


1. C program to convert number from Decimal to Binary.
2. C program to convert number from Decimal to Octal.
3. C program to convert number from Decimal to Hexadecimal.
4. C program to convert number from Binary to Decimal.
5. C program to convert number from Octal to Decimal.
6. C program to convert number from Hexadecimal to Decimal.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.

/*C program to convert number from decimal to binary*/


#include <stdio.h>
int main()
{
int
number,cnt,i;
int
bin[32];
printf("Enter decimal number: ");
scanf("%d",&number);
cnt=0;
/*initialize index to zero*/
while(number>0)
{
bin[cnt]=number%2;
number=number/2;
cnt++;
}
/*print value in reverse order*/
printf("Binary value is: ");
for(i=(cnt-1); i>=0;i--)
printf("%d",bin[i]);

32.
33. }

return 0;

34. Decimal

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

to Octal Conversion using C program

/*C program to convert number from decimal to octal*/


#include <stdio.h>
int main()
{
int
number,cnt,i;
int
oct[32];
printf("Enter decimal number: ");
scanf("%d",&number);

cnt=0;
/*initialize index to zero*/
while(number>0)
{
oct[cnt]=number%8;
number=number/8;
cnt++;
}
/*print value in reverse order*/
printf("Octal value is: ");
for(i=(cnt-1); i>=0;i--)
printf("%d",oct[i]);
return 0;
}

List of C programming Bitwise related programs.

1. Program to get binary number of a decimal number.


2. Program to get minimum number of bits to store an integer number.
3. Program to swap bytes [for example convert 0x1234 to 0x3412].
4. Program to swap two bits.
5. Program to reverse bits of a number.
6. Program to count number of 1's in a number.
7. Program to swap nibbles of a byte/word.
8. Program to demonstrate left shift (<<) operator.
9. Program to demonstrate right shift (>>) operator.
10. Program to set/clear (low/high) bits of a number.
11. Program to swap two numbers using bitwise operator.

Half, Full, Incremented and Decrement Stars Series, Pyramid Pattern


programs
Program - 1
1

/*C program to print following Pyramid:

**

***

5
6
7

****
*****
*/

8
9
10

#include<stdio.h>

#define MAX 5

11
12
13
14

int main()
{
int i,j;

15
16
for(i=0; i< MAX; i++)

17

18

for(j=0;j<=i;j++)

19

20

printf("*");

21

22

printf("\n");

23

24
25

return 0;
}

26
*
**
***
****
*****

Program - 2
1

/*C program to print following Pyramid:

*****

****

***

5
6
7

**
*
*/

8
9

#include<stdio.h>

10
11

#define MAX 5

12
13
14

int main()
{

15

int i,j;

16
17

for(i=MAX; i>=0; i--)

18

19

for(j=0;j<=i;j++)

20

{
printf("*");

21
}

22

printf("\n");

23
}

24

return 0;

25
26

*****
****
***
**
*

Program - 3
1

/*C program to print following Pyramid:

* *

* * *
* * * *

* * * * *

6
7

*/

8
#include<stdio.h>

9
10

#define MAX 5

11
12
13
14

int main()
{
int i,j;

15

int space=4;

16

/*run loop (parent loop) till number of rows*/

17

for(i=0;i< MAX;i++)

18

19

/*loop for initially space, before star printing*/

20

for(j=0;j< space;j++)

21

{
printf(" ");

22
23
24
25

}
for(j=0;j<=i;j++)
{
printf("* ");

26
27

28
29

printf("\n");

30

space--;

31

32

return 0;

/* decrement one space after one row*/

33
34
*

**
***
****
*****

1) C program to find sum of all natural numbers.


Series: 1+2+3+4+..N
2) C program to find sum of the square of all natural numbers from 1 to N.
Series: 1^2+2^2+3^2+4^2+..N^2
3) C program to find the sum of Natural Number/Factorial of Number of all
natural numbers from 1 to N.
Series: 1/1! + 2/2! + 3/3! + 4/4! + ... N/N!
4) C program to find sum of following series:
1+ 1/2 + 1/3 + 1/4 + 1/5 + .. 1/N
5) C program to find sum of following series:
1 + 3^2/3^3 + 5^2/5^3 + 7^2/7^3 + ... till N terms
List of One Dimensional Array Programs / Examples in C
1. C program to read and print One Dimensional Array of integer elements.
2. C program to calculate Sum, Product of all elements.

3. C program to find Smallest and Largest elements from One Dimensional Array
Elements.
4. C program to replace all EVEN elements by 0 and Odd by 1 in One Dimensional
Array.
5. C program to merge Two One Dimensional Arrays elements.
6. C program to Add and Subtract of Two One Dimensional Array elements.
7. C program to find a number from array elements.
8. C program to sort array elements in ascending order.
9. C program to reverse array element.
10. C program to swap adjacent elements of a one dimensional array
11. C program to find occurrence of an element in one dimensional array.
12. C program to sort an one dimensional array in ascending order.
13. C program to sort an one dimensional array in descending order.
14. C program to delete given element from one dimensional array.
15. C program to create array with reverse elements of one dimensional array.

c
c
c
c
c
c
c

program
program
program
program
program
program
program

to
to
to
to
to
to
to

read and print a rxc matrix, r and c must be input by the user.
read a matrix and find sum and product of all elements.
find sum of all elements of each row of a matrix.
transpose a matrix.
read a matrix and print diagonals.
find sum and subtraction of two matrices.
find multiplication of two matrices

program to create, declare and initialize structure. program to read and print an
employee's detail using structure. program to demonstrate example of nested
structure.program to demonstrate example structure pointer (structure with
pointer).program to demonstrate example structure pointer (structure with pointer)
using user define function.program to declare, initialize an union, example of
unionprogram to demonstrate example of structure of array. program to add two
distances in feet and inches using structure.


Program to create, open and close a file.
Program to write text (characters) into file and print.
program to print given number of lines of a file (like head command in Linux).
program to print contents in reverse order of a file (just like TAC command in Linux).
program to compare contents of two files.
program to copy number of bytes of from a specific offset to another file.
C - Read Content of a File using getc() using C Program.
(From C Code Snippet Section)

C - Convert All Characters in Upper Case of a File using C Program.

(From C Code Snippet Section)

Вам также может понравиться