C Program for Adding Two Numbers Using Recursion

c program to add 2 numbers

C Program for Adding Two Numbers Using Recursion #include<stdio.h> int y; /* Function to add two numbers and return the result */ int add(int m, int n) { if(n == 0) return m; /* Recursion: adding 1, n times and then at the end adding m to it */ y = add(m, n-1) + 1; … Read more

C Program find whether a Number is Prime Or Composite using Recursion

prime number

C Program find whether a Number is Prime Or Composite using Recursion Prime Number: A number that is only divisible by 1 and itself. Composite Number: A number that is not a prime number. Note: 1 is neither prime nor composite. Below is a program to find whether the user input number is a prime number or a … Read more

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); }  

C Program to check whether the given integer is positive or negative

#include <stdio.h> void main() { int num; printf(“Enter a number: \n”); scanf(“%d”, &num); if (num > 0) printf(“%d is a positive number \n”, num); else if (num < 0) printf(“%d is a negative number \n”, num); else printf(“0 is neither positive nor negative”); }

C Program to Find Quotient and Remainder

  #include <stdio.h> int main(){ int num1, num2, quot, rem; printf(“Enter dividend: “); scanf(“%d”, &num1); printf(“Enter divisor: “); scanf(“%d”, &num2); quot = num1 / num2; rem = num1 % num2; printf(“Quotient is: %d\n”, quot); printf(“Remainder is: %d”, rem); return 0; }  

C Program to Sort set of strings in alphabetical order

#include<stdio.h> #include<string.h> int main(){ int i,j,count; char str[25][25],temp[25]; puts(“How many strings u are going to enter?: “); scanf(“%d”,&count); puts(“Enter Strings one by one: “); for(i=0;i<=count;i++) gets(str[i]); for(i=0;i<=count;i++) for(j=i+1;j<=count;j++){ if(strcmp(str[i],str[j])>0){ strcpy(temp,str[i]); strcpy(str[i],str[j]); strcpy(str[j],temp); } } printf(“Order of Sorted Strings:”); for(i=0;i<=count;i++) puts(str[i]); return 0; }

C program to convert time in Hours:Minutes:Seconds to seconds

c program to add 2 numbers

C program to convert time in Hours:Minutes:Seconds to seconds /* C program to convert time in hours:minutes:seconds to seconds */ #include <stdio.h> int main() { int hour, minute, second, timeinsec; printf(“Enter the value for hour:”); /* get hour value from user*/ scanf(“%d”, &hour); printf(“Enter the value for minute:”); /* get minute value from user */ … Read more

Selection Sort Algorithm

sorting algorithm

Selection Sort Algorithm Selection sort is an algorithm that selects the smallest element from an unsorted list in each iteration and places that element at the beginning of the unsorted list. The Selection sort algorithm is based on the idea of finding the minimum or maximum element in an unsorted array and then putting it … Read more

C Program to Check whether an Alphabet is Vowel or Consonant

c program to check vowel and consonant

C Program to Check whether an Alphabet is Vowel or Consonant This program takes the character value(entered by user) as input and checks whether that character is a vowel or consonant using if-else statement. Since a user is allowed to enter an alphabet in lowercase and uppercase, the program checks for both uppercase and lowercase … Read more

Merry Christmas – Program for Christmas Tree in C

merry christmas program in c

Merry Christmas – Program for Christmas Tree in C   To print a Christmas tree, we are printing pyramids of various sizes just one beneath the other. For the decoration, a random character is printed at each position. Height and randomness can be adjusted. This is been repeated frame after frame to give the illusion of a true event. … Read more