-
Geeks for Geeks Sudo placement: Immediate Smaller Element in array in C language
The code below is Geeks for Geeks Sudo placement challenge for checking immediate smaller Element in an array and printing the desired output. Geeks for Geeks challenge(Sudo Placement): Given an integer array, for each element in the array check whether there exists a smaller element on the next immediate position of the array. If it exists print the…
-
A program using single subscribed variable to evaluate the expression in C language
The following C program is used to evaluate the following expression: Total = Σ i=110 Xi2 where X1, X2 … X10 they are user inputs. The code has been tested in Dev c++. CODE: #include<stdio.h> void main(){ int i; float x[10],value,total; printf(“Enter 10 REAL Numbers”); for(i=0;i<10;i++){ scanf(“%f”,&value); x[i]=value; } total=0.0; for(i=0;i<10;i++){ total = total +x[i]*x[i]; printf(“\n”);…
-
Program to sort the elements of an array in descending order in C language
The program below sort the elements of an array in descending order. It uses malloc function to allocate the space for number of elements that user enters. The code is pretty forward. With sizeof(), the program is taking the size of the n variable that’s taking the value from the user and with that value malloc…
-
Program to evaluate Graph equation y=x^n using C Language
This is the program to evaluate graph equation y=xn. This code works with non negative integers. The following code has been written and compiled in Dev c++. Code: #include<stdio.h> void main(){ int count,n; float x,y; printf(“enter the value of X and N \n”); scanf(“%f%d”,&x,&n); y=1.0; count=1; while(count<=n){ y=y*x; count++; } printf(“\nX = %.3f, N =…
-
Program to find factorial of a number using recursive function in C language
This article is a program to find factorial in C language using recursive function. Before going straight to the code, let’s talk about Recursive functions and what are they? Recursive function is a tricky topic in C. They are the functions which calls themselves. So whenever you see a function which contains its own name…
-
Program to find factorial of a number using function in C language
Below is the program to find factorial of a number using function in C language. The program has been compiled and executed in Dev C++. The function is a block of code that is specifically designed to do a certain task. Here, the function is taking an argument and calculating the factorial returning its resulting…
-
Program to display series and find sum of 1+3+5+…+n in C language
The series 1+3+5+..+n, is a series of odd number. We need to write a program to display this series as well as find the sum upto nth number. The n will be inserted by the user. The program has been compiled and executed under DEV c++. CODE: #include void main() { int i,n,sum=1; printf(“Enter any…
-
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 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
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
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;…