INDEX S.No . Program Page Date Sig n 1. Program in C, to calculate area and circumference of the circle. 2. Program in C, to find the real roots of a quadratic equation. 3. Program in C, to find whether a number is odd or even. 4. Program in C, to find largest, second largest and smallest among the given three numbers. 5. Program in C, to calculate grade of a student having three subjects .The calculation of grade be according to the condition as following: If percentage >=80 then grade A If percentage>=60 but <80% then grade B If percentage>=40 but <60% then grade C Otherwise fail 6. Program in C, to find the reverse of a given integer number. 7. Program in C, to find the factorial of a given number. 8. Program in C, to print prime numbers between 1 to 100. 9. Program in C, to print the following Series. a). 1 b). * 2 1 * * 3 2 1 * * * 4 3 2 1 * * * * 10. Program in C, to perform arithmetic calculations on integers using switch case statement 11. Program in C, to find maximum and minimum element in a given array 12. Program in C, to perform addition of two matrices 13. Program in C, to perform multiplication of two matrices 14. Program in C, to find X to power Y using user
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
INDEX
S.No. Program Page Date Sign
1. Program in C, to calculate area and circumference of the circle.
2. Program in C, to find the real roots of a quadratic equation.
3. Program in C, to find whether a number is odd or even.
4.Program in C, to find largest, second largest and smallest among the given three numbers.
5.
Program in C, to calculate grade of a student having three subjects .The calculation of grade be according to the condition as following:If percentage >=80 then grade AIf percentage>=60 but <80% then grade BIf percentage>=40 but <60% then grade COtherwise fail
6. Program in C, to find the reverse of a given integer number.
7. Program in C, to find the factorial of a given number.
8. Program in C, to print prime numbers between 1 to 100.
9.
Program in C, to print the following Series. a). 1 b). * 2 1 * * 3 2 1 * * * 4 3 2 1 * * * *
10.Program in C, to perform arithmetic calculations on integers using switch case statement
11.Program in C, to find maximum and minimum element in a given array
12. Program in C, to perform addition of two matrices
13. Program in C, to perform multiplication of two matrices
14. Program in C, to find X to power Y using user defined function
15. Program in C, to swap two numbers using call by reference
16.Program in C, to generate first 25 Fibonacci numbers using recursion
S.No. Program Page Date Sign
17.Program in C, to process the student data –name, class, roll number using structures
18 Program in C, to compare two strings using strcmp () function
19.Program in C, to find whether a string is palindrome or not without using string functions
20. Program in C, to sort given elements of array using bubble sort
21.Program in C, to sort given elements of array using selection sort
22. Program in C, to search an element using linear search
23. Program in C, to search an element using binary search
24. Program in C, to copy contents of one file to another
25.Program in C, to count number of characters, vowels, constant and words in a given file.
1. Program in C, to calculate area and circumference of the circle.
3. Program in C, to find whether a number is odd or even.
#include <stdio.h>
void main(){
int n;
printf("\nEnter a Number: ");scanf("%d" , &n);
if(n%2 == 0)printf("\n%d is EVEN" , n);
elseprintf("\n%d is ODD" , n);
}
4. Program in C, to find largest, second largest and smallest among the given three numbers.
#include <stdio.h>
main(){
float n1 , n2 , n3;
printf("\nEnter 1st Number: ");scanf("%f" , &n1);
printf("\nEnter 2nd Number: ");scanf("%f" , &n2);
printf("\nEnter 3rd Number: ");scanf("%f" , &n3);
printf("\nSmallest < Second Largest < Largest");
if(n1 < n2 && n2 < n3){
printf("\n%f < %f < %f" , n1 , n2 , n3);}
else if(n1 < n3 && n3 < n2){
printf("\n%f < %f < %f" , n1 , n3 , n2);}
else if(n2 < n1 && n1 < n3){
printf("\n%f < %f < %f" , n2 , n1 , n3);}
else if(n2 < n3 && n2 < n1){
printf("\n%f < %f < %f" , n2 , n3 , n1);}
else if(n3 < n1 && n1 < n2){
printf("\n%f < %f < %f" , n3 , n1 , n2);}
else if(n3 < n2 && n2 < n1){
printf("\n%f < %f < %f" , n3 , n2 , n1);}
}
5.
Program in C, to calculate grade of a student having three subjects .The calculation of grade be according to the condition as following:If percentage >=80 then grade AIf percentage>=60 but <80% then grade BIf percentage>=40 but <60% then grade COtherwise fail
#include <stdio.h>
main(){
float p;
printf("\nPercentage of Student ? : ");scanf("%f" , &p);
if(p >= 80)printf("\nGrade = A");
else if(p >= 60 && p < 80)printf("\nGrade = B");
else if(p >= 40 && p < 60)printf("\nGrade = C");
elseprintf("\nFail");
}
6. Program in C, to find the reverse of a given integer number.
#include <stdio.h>
main(){
long unsigned n, rev , rem ;
char c;
do{
rev=0;
printf("\n\nEnter number: ");scanf(" %lu" , &n);
while(n > 0){
rem = n%10;rev = rev * 10 + rem;n = n/10;
}
printf("\nReverse of the number is: %lu" , rev);
printf("\n\nRepeat again? ");scanf(" %c" , &c);
}while((c == 'y')||(c == 'Y'));
printf("\n<<Good Bye!>>");}
7. Program in C, to find the factorial of a given number.
#include <stdio.h>
main(){
int n ;long unsigned fact = 1 ;
printf("\nEnter Number : ");scanf("%d" , &n);
if(n==1)printf("%d ! (factorial) = %d" , n , fact);
char s1[20] , s2[20];clrscr();printf("\nEnter a string: ");scanf("%s",s1);strcpy(s2 , s1);strrev(s2);if(strcmp(s1,s2)==0)printf("\"%s\" is a PALINDROME",s1);elseprintf("\"%s\" is NOT a PALINDROME",s1);getch();
}
20. Program in C, to sort given elements of array using bubble sort
#include <stdio.h>#define size 50
main(){
int a[size] , i , j , temp , value , n = 0 , index = -1;
printf("\nEnter Array Elements:\n[Enter 0 (zero) to Stop]\n");
for( i = 0 ; i < size ; i++){
printf("\nA[%d] = ",i);scanf("%d", &value);
if(value == 0){
break;}else{
a[i] = value;n++;
}}
puts("\n\nThe Array you have Entered is:\n");
for (i = 0 ; i < n ; i++){
printf("\nA[%d] = %d", i , a[i]);}
for (i = 0 ; i < n ; i++){
for (j = i+1 ; j < n ; j++){
if(a[i] > a[j]){
temp = a[i];a[i] = a[j];a[j] = temp;
}}
}
puts("\n\nAfter Bubble Sort:\n");
for (i = 0 ; i < n ; i++){
printf("\nA[%d] = %d", i , a[i]);}
}
21. Program in C, to sort given elements of array using selection sort
22. Program in C, to search an element using linear search
#include <stdio.h>#define size 50
main(){
int a[size] , i , value , n = 0 , index = -1;
printf("\nEnter Array Elements:\n[Enter 0 (zero) to Stop]\n");
for( i = 0 ; i < size ; i++){
printf("\nA[%d] = ",i);scanf("%d", &value);
if(value == 0){
break;}else{
a[i] = value;n++;
}}
for (i = 0 ; i < n ; i++){
printf("\nA[%d] = %d", i , a[i]);}
printf("\n\nEnter Item to Search: ");scanf("%d",&value);
for (i = 0 ; i <= n ; i++){
if(a[i] == value){
index = i; break;
}}
if(index == -1){
printf("\nItem not found");}else{
printf("\nItem found at Index: %d", index);}
}
23. Program in C, to search an element using binary search
#include <stdio.h>#define size 50
main(){
int a[size] , i , j , temp , value , n = 0 , index , beg , end , mid;
printf("\nEnter Array Elements:\n[Enter 0 (zero) to Stop]\n");
for( i = 0 ; i < size ; i++){
printf("\nA[%d] = ",i);scanf("%d", &value);
if(value == 0){
break;}else{
a[i] = value;n++;
}}
for (i = 0 ; i < n-1 ; i++){
for (j = i+1 ; j < n ; j++){
if(a[i] > a[j]){
temp = a[i];a[i] = a[j];a[j] = temp;
}}
}
printf("\n\nArray after Bubble Sort:");
for (i = 0 ; i < n ; i++){
printf("\nA[%d] = %d", i , a[i]);}
printf("\n\nEnter Item to search: ");scanf("%d" , &value);