Professional Documents
Culture Documents
Basic Program
1 Program to Find Sum and Average of Three Real Numbers
2 Program to Find Area of Square and Circumference of a Circle
3 Program to find Sphere Surface Area and Volume of a Sphere
4 Program to Find Area of a Triangle using Hero Formula
5 Program to Find Simple Interest and Compound Interest
6 Program to Convert Temperature from Degree Centigrade to Fahrenheit
7 Program to Convert Time in Seconds to Hours Minutes and Seconds
8 Program to Swap Values of Two Variables using Third Variable
9 Program to Swap Values of Two Variables Without using Third Variable
10 Program to Calculate the Net Salary
1 Program to Find Largest of Three Numbers
Control Statements & Loop
1 Program to Check Whether a Character is Vowel or not by using switch
Statement1
2 Program to Find the Sum of First 100 Positive Integers2
3 Program to Find the Sum of Even and Odd Numbers from First 100 Positive
Integers
4 Program to Find the Sum of Digits of a Positive Integer
5 Program to Find Whether the Given Number is a Prime Number
6 Program to Print First N Prime Numbers
7 Program to Print a Table of any Number
8 Program to Check Whether the Given Number is an Armstrong Number
9 Program to Print the Numbers Which are Divisible by 3 and 5 from First 100
Natural Numbers
10 Program to Find Whether a Number is Palindrome or Not
11 Program to Find Factorial of a Number without using Recursion
12 Program to Find Factorial of a Number using Recursion
13 Program to Print Fibonacci Series without Recursion
14 Program to Print Fibonacci Series using Recursion
15 Program to Reverse a Given Number
16 Program to Find Value of sinx using Expansion Series given below:
17 sin(x) = x - x3/3 + x5/5 - x7/7......
18 Program to Find HCF of Two Numbers using Recursion
19 Program to Find HCF of Two Numbers Without Recursion
20 Program to Find Vowels in a String
21 Program to Count Number of Words and Number of Characters in a String
22 Program to Implement break Statement
23 Program to Implement continue Statement
Array
1 Program to Print Transpose of a Matrix
2 Program to Add Two Matrices
3 Program to Multiply Two Matrices
4 Program to Find Smallest Among N Numbers
5 Program to Illustrate the Concept of Passing 1-D Array to Function
6 Program to Illustrate the Concept of Passing 2-D Array to Function
7 Program to Sort an Array Using Bubble Sort
8 Program to Sort an Array Using Selection Sort
9 Program to Search an Array using Linear Search
Strings
1 Program to Concatenate Two Strings using strcat( )
2 Program to Concatenate Two Strings without using strcat( )
3 Program to Compare Two Strings using strcmp( )
4 Program to Compare Two Strings without using strcmp( )
5 Program to Copy String using strcpy( )
6 Program to Copy String without using strcpy( )
7 Program to Find Length of a String using strlen( )
8 Program to Reverse a String using strrev( )
9 Program to Reverse a String without using strrev( )
10 Program to Input-Output Strings using Character Functions
11 Program to Input-Output Strings using gets( ) and puts( )
12 Program to Input-Output Strings using printf( ) and scanf( )
13 Program to Find Length of a String Without using strlen( )
14 Program to Find Whether a String is Palindrome or Not
15 Program to Find Whether a String is Palindrome or Not without using String
Functions
Functions
1 Program to Show Call by Value
2 Program to Show Call by Reference
Recursion
1 Program to Find Factorial of a Number using Recursion
2 Program to Print Fibonacci Series using Recursion
3 Program to Find HCF of Two Numbers using Recursion
Pointers
1 Program to Illustrate the Concept of Pointers
1 Program to Implement Structure
2 Program to Implement Structure with Array
3 Program to Implement Structure with Function
4 Program to Implement Structure with Pointers
Searching & Sorting
1 Program to Search an Element in the Array using Linear Search
2 Program to Search an Array using Binary Search
3 Program to Sort an Array using Bubble Sort
4 Program to Sort an Array using Selection Sort
File Handling
1 Program to Write and Read a Character from a File
2 Program to Write and Read an Integer from a File
3 Program to Write and Read a String from a File
4 Program to Write Data into a File using fprintf( )
5 Program to Read Data from File using fscanf( )
6 Program to Copy Contents of One File to Another
7 Program to Print a File and Count Number of Characters
Simple C Programs
Control Statements
switch Statement
*/
#include <stdio.h>
main()
{
char ch;
printf("\nEnter any character: ");
scanf("%c", &ch);
switch (ch)
{
case 'a':
case 'A':
printf("\n\n%c is a vowel", ch);
break;
case 'e':
case 'E':
printf("\n\n%c is a vowel", ch);
break;
case 'i':
case 'I':
printf("\n\n%c is a vowel", ch);
break;
case 'o':
case 'O':
printf("\n\n%c is a vowel", ch);
break;
case 'u':
case 'U':
printf("\n\n%c is a vowel", ch);
break;
default:
printf("\n\n%c is not a vowel", ch);
}
getch();
Program to Find the Sum of Even and Odd Numbers from First 100
Positive Integers
*/
#include <stdio.h>
main()
{
int i, sumEven=0, sumOdd=0;
for (i=0; i<=100; i++)
if (i%2 == 0)
sumEven = sumEven + i;
else
sumOdd = sumOdd + i;
printf("\nSum of first even 100 numbers: %d\n", sumEven);
printf("\nSum of first odd 100 numbers: %d\n", sumOdd);
getch();
}
Program to multiply two matrices. The order and the elements of the
two matrices will be entered by the user as input to the program
and if multiplication is not possible then it should be reported to
the user
*/
#include <stdio.h>
main()
{
int a[10][10], b[10][10], c[10][10], i, j, k, r1, r2, c1, c2;
back:
printf("\nEnter no. of rows and columns of Matrix A: ");
scanf("%d %d", &r1, &c1);
printf("\nEnter no. of rows and columns of Matrix B: ");
scanf("%d %d", &r2, &c2);
if (c1 != r2)
{
printf("\n\nMultiplication is not possible\n");
goto back;
}
printf("\n\nEnter elements of Matrix A:\n");
for (i=0; i<r1; i++)
for (j=0; j<c1; j++)
scanf("%d", &a[i][j]);
printf("\nEnter elements of Matrix B:\n");
for (i=0; i<r2; i++)
for (j=0; j<c2; j++)
scanf("%d", &b[i][j]);
printf("\n\nElements of Matrix A:\n\n");
for (i=0; i<r1; i++)
{
for (j=0; j<c1; j++)
printf("\t%d", a[i][j]);
printf("\n\n");
}
printf("\n\nElements of Matrix B:\n");
for (i=0; i<r2; i++)
{
for (j=0; j<c2; j++)
printf("\t%d", b[i][j]);
printf("\n\n");
}
for (i=0; i<r1; i++)
for (j=0; j<c2; j++)
{
c[i][j] = 0;
for (k=0; k<r2; k++)
c[i][j] = c[i][j] + a[i][k] * b[k][j];
}
printf("\n\nMultiplication of Matrices:\n\n");
for (i=0; i<r1; i++)
{
for (j=0; j<c2; j++)
printf("\t%d", c[i][j]);
printf("\n\n");
}
getch();
}
/*
Program to Illustrate the Concept of Passing 1-D Array to Function
Program to Find Largest from an Array
*/
#include <stdio.h>
#define SIZE 50
int big(int [], int);
main()
{
int a[SIZE], n, i, b;
printf("\nEnter size of array: ");
scanf("%d", &n);
printf("\nEnter elements:\n");
for (i=0; i<n; i++)
scanf("%d", &a[i]);
b = big(a, n);
printf("\nLargest number: %d", b);
getch();
}
int big(int a[], int n)
{
int b, i;
b = a[0];
for (i=0; i<n; i++)
if (a[i] > b)
b = a[i];
return b;
}
Strings
Recursion
Pointers
Structures
File Handling