Category: Programming challenges

  • Program to show Call by Value and Call by Reference in C Language

    Program to show Call by Value and Call by Reference in C Language

    This article will illustrate the use of Call by Value and Call by Reference in C Programming language. C Language provide several features. Before, we talk about call by reference and call by value, let’s have a little talk about functions in C because both of them are used within the functions itself. A function…

  • Program to find Sum of two matrix in C Language

    Below is the program to find the sum of two matrics in C language. You can edit it to your needs if you want to. I have taken two matrix with 3 X 2. You can change it. The following code has been executed in Dev C++ and will also work with Ubuntu gcc. Code:…

  • Program to print Transpose of a matrix in C language

    The following program print the transpose of the matrix in C. The transpose of a matrix makes the row to column and column to row. If the matrix is in the form a[3][2] then the transpose of such a matrix will be a[2][3]. About the Code: The code is written in two dimensional array taking…

  • Program to display sum of series 1+1/2+1/3+…+1/n in C language

    Program to display sum of series 1+1/2+1/3+…+1/n in C language

    The following C program is to find the sum of the series 1+1/2+1/3+…+1/n. The following code have been compiled and executed in Dev C++. Information about the code:  > The variable is taken as double here. Int datatype will not be used here or else the generated output will be wrong. > %.3lf prints 3…

  • Program to Reverse a number in C language

    Program to Reverse a number in C language

    The following program will show how you can reverse a particular number in C language. The code has been written and compiled in Dev C++. code: #include void main(){ int n,a,r=0; printf(“Enter any number: “); scanf(“%d”,&n); while(n>=1) { a=n%10; r=r*10+a; n=n/10; } printf(“Reverse = %d”,r); } OUTPUT:

  • Program to Calculate Simple Interest in C language

    Program to Calculate Simple Interest in C language

    This is the C program to calculate Simple Interest. We calculate simple interest to calculate interest charge on the loan. The following C program has been written and compiled on Dev C++. Code: #include<stdio.h> void main(){ int t; float p,r,si; printf(“Enter the Principle:”); scanf(“%f”,&p); printf(“Enter the Rate Of Interest:”); scanf(“%f”,&r); printf(“Enter the Time:”); scanf(“%d”,&t); si=(p*r*t)/100;…

  • Finding Area and Circumference of Circle in C Language

    C program for calculating Area and Circumference of the Circle in C language. In this program, we are taking the input for the Radius. The value for pi, area and ci [circumference] is float. So I have defined it with Float datatype. Area of the Circle :  Pie * (r)^2 Circumference : 2 * Pie…

  • C Program to Compare two Strings

    C Program to Compare two Strings

    This C program compares two string and tell if they are equal or not. We are taking two strings here str and str1. It is an array with 30 indexes. There are two int variables i and j which will be used to evaluate the strings. The while loops runs upto end of str[] string,…

  • Program to reverse a string in C Language

    The program below shows how you can reverse a string in c program. In this program I have used two arrays,one array is for the actual string to reverse and another array will keep the reversed string. The while function read the string from last to first and put each character in rev array. Code:…

  • C Program to Swap two numbers with and without third variable

    C Program to Swap two numbers with and without third variable

    There are two ways to swap numbers using C language, one is with the help of temporary third variable and other is without the third variable. In this article, we will be looking at both of those approaches. Program to swap two number in C using Third/Temporary variable: #include<stdio.h> void main(){ int a,b,temp; printf(“Enter Two…

  • Program to Convert Celsius to Fahrenheit in C Language

    This article will show you the C program to convert temperature in Celsius to Fahrenheit. The Formula for conversion is: 1.8 * C + 32 Code: #include<stdio.h> void main(){ int a; float i=1; printf(“\n********************************\nprogram to convert Celsius to Fahrenheit\n***********************************\n\n”); printf(“Enter Temperature in Celsius: “); scanf(“%d”,&a); i=(1.8 * a) +32; printf(“Fahrenheit Temperature is : %.3f\n”,i); }…

  • Program to find GCD of two numbers in C language

    Program to find GCD of two numbers in C language

    The following program is to find the GCD or HCF of a number using C Language. GCD is the Greatest Common Divisor that divides a particular number. #include<stdio.h> void main(){ int a,b,i,j; printf(“\n****************************\nprogram to find GCD of 2 Numbers\n*****************************\n\n”); printf(“Enter two numbers: “); scanf(“%d%d”,&a,&b); printf(“Common Factors for %d and %d are: “,a,b); j=a>b?b:a; for(i=1;i<=j;i++){ if(a%i==0…