C program to find the length of a String without using function strlen()

#include <stdio.h> int main() { char str[100],i; printf(“Enter a string: \n”); scanf(“%s”,str); for(i=0; str[i]!=’\0′; ++i); printf(“\nLength of input string: %d”,i); return 0; }  

C Program to calculate Area of Equilatral triangle

#include<stdio.h> #include<math.h> int main() { int triangle_side; float triangle_area, temp_variable; printf(“\nEnter the Side of the triangle:”); scanf(“%d”,&triangle_side); temp_variable = sqrt(3) / 4 ; triangle_area = temp_variable * triangle_side * triangle_side ; printf(“\nArea of Equilateral Triangle is: %f”,triangle_area); return(0); }  

C Program to calculate Area and Circumference of Circle

#include <stdio.h> int main() { int circle_radius; float PI_VALUE=3.14, circle_area, circle_circumf; printf(“\nEnter radius of circle: “); scanf(“%d”,&circle_radius); circle_area = PI_VALUE * circle_radius * circle_radius; printf(“\nArea of circle is: %f”,circle_area); circle_circumf = 2 * PI_VALUE * circle_radius; printf(“\nCircumference of circle is: %f”,circle_circumf); return(0); }  

Quicksort program in C

  #include<stdio.h> void quicksort(int number[25],int first,int last){ int i, j, pivot, temp; if(first<last){ pivot=first; i=first; j=last; while(i<j){ while(number[i]<=number[pivot]&&i<last) i++; while(number[j]>number[pivot]) j–; if(i<j){ temp=number[i]; number[i]=number[j]; number[j]=temp; } } temp=number[pivot]; number[pivot]=number[j]; number[j]=temp; quicksort(number,first,j-1); quicksort(number,j+1,last); } } int main(){ int i, count, number[25]; printf(“How many elements are u going to enter?: “); scanf(“%d”,&count); printf(“Enter %d elements: “, count); … Read more

Insertion Sort Program in C

#include<stdio.h> int main(){ int i, j, count, temp, number[25]; printf(“How many numbers u are going to enter?: “); scanf(“%d”,&count); printf(“Enter %d elements: “, count); for(i=0;i<count;i++) scanf(“%d”,&number[i]); for(i=1;i<count;i++){ temp=number[i]; j=i-1; while((temp<number[j])&&(j>=0)){ number[j+1]=number[j]; j=j-1; } number[j+1]=temp; } printf(“Order of Sorted elements: “); for(i=0;i<count;i++) printf(” %d”,number[i]); return 0; }  

C Program to find the Sum of First n Natural numbers

#include <stdio.h> int main() { int n, count, sum = 0; printf(“Enter the value of n(positive integer): “); scanf(“%d”,&n); for(count=1; count <= n; count++) { sum = sum + count; } printf(“Sum of first %d natural numbers is: %d”,n, sum); return 0; }  

C Program to check if a number is palindrome or not

  #include <stdio.h> int main() { int num, reverse_num=0, remainder,temp; printf(“Enter an integer: “); scanf(“%d”, &num); temp=num; while(temp!=0) { remainder=temp%10; reverse_num=reverse_num*10+remainder; temp/=10; } if(reverse_num==num) printf(“%d is a palindrome number”,num); else printf(“%d is not a palindrome number”,num); return 0; }

C Program to check whether a Character is an Alphabet or not

  #include <stdio.h> int main() { char ch; printf(“Enter any character: “); scanf(“%c”,&ch); if( (ch>=’a’ && ch<=’z’) || (ch>=’A’ && ch<=’Z’)) printf(“The entered character %c is an Alphabet”,ch); else printf(“The entered character %c is not an Alphabet”,ch); return 0; }  

write a C program to calculate the sum of its digits

C Programming Tutorial

Problem Statement: If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. Answer: /* Sum of digits of a 5 digit number*/ #include<stdio.h> #include<conio.h> main() { int num,a,n; int sum=0; /* this has been initialised to zero otherwise it will contain a garbage value */ clrscr(); … Read more