Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 1219 of 2650
2K+ Views
Reducing the fraction to the lowest terms means that there is no number, except 1, that can be divided evenly into both the numerator and the denominator.For example, 24/4 is a fraction, the lowest term for this fraction is 6, or 12/16 is a fraction the lowest term is 3/4.Now let’s write a c program to reduce the fraction into their lowest terms.Example 1 Live Demo#include int main(){ int x, y, mod, numerat, denomi, lessnumert, lessdenomi; printf("enter the fraction by using / operator:"); scanf("%d/%d", &x, &y); numerat=x; denomi=y; switch(y){ case 0:printf("no zero's ... Read More
14K+ Views
Constant is a value that cannot be changed during program execution; it is fixed.In C language, a number or character or string of characters is called a constant. And it can be any data type. Constants are also called as literals.There are two types of constants −Primary constants − Integer, float, and character are called as Primary constants.Secondary constants − Array, structures, pointers, Enum, etc., called as secondary constants.Syntaxconst datatype variable;Example for Primary constants Live Demo#include int main(){ const int height=20; const int base=40; float area; area=0.5 * height*base; printf("The area of triangle :%f", area); ... Read More
7K+ Views
ProblemGenerate the greatest common divisor for any two numbers using C programming language.SolutionLet the user enter any two numbers from the console. For those two numbers, let’s find the greatest common divisor.The GCD of two numbers is the largest number that exactly divides both of them without a remainder.The logic we use to find the GCD of two numbers is as follows −while(b!=0) //check for b=0 condition because in a/b ,b should not equal to zero { rem=a % b; a=b; b=rem; } Print aProgram 1 Live Demo#include int main(){ ... Read More
7K+ Views
ProblemIs it possible to convert the given one or two-digit numbers into English words by using the C Programming language?SolutionWe can easily convert the given two-digit number into English word format with the help of a switch case. Not only two digits, but any number can also convert into English like a statement in C.In this program, we will convert one or two-digit numbers into English word format.Example Live Demo#include int main(){ int no; printf("enter any 1 or 2 digit number:"); scanf("%d", &no); if(no=99) //finding out whether enter no is 2 digit or not ... Read More
18K+ Views
ProblemLet the user enter four series of integers in the console, find out a number which is smallest and largest in a seriesSolutionTo calculate the small and large number, we use if conditions. The logic we use to find the largest and smallest number is −if(minno>q) //checking 1st and 2nd number minno=q; else if(maxno&l;q) maxno=q; if(minno>r) //checking 1st and 3rd number minno=r;Program 1 Live Demo#include int main(){ int minno, maxno, p, q, r, s; printf("enter any four numbers:"); scanf("%d%d%d%d", &p, &q, &r, &s); minno=p; maxno=p; if(minno>q) //checking 1st and 2nd number ... Read More
1K+ Views
ProblemHow to convert the time from 24 hr format to 12 hr format using C Programming language?SolutionRead the time value from the user (at run time). It has to be converted into 12 hr format from 24 hr.AlgorithmStart: Step 1: Enter time in 24 hr format Step 2: check the condition i. If(hour==0) Print min Ii. Elseif(hour
53K+ Views
Transpose of a matrixThe transpose of a matrix is the one whose rows are columns of the original matrix, i.e. if A and B are two matrices such that the rows of the matrix B are the columns of the matrix A then Matrix B is said to be the transpose of Matrix A.The logic used to change m(i, j) matrix to m(j, i) is as follows −for (i = 0;i < m;i++) for (j = 0; j < n; j++) transpose[j][i] = matrix[i][j];Program 1In this example, we shall print the transpose of a matrix using for ... Read More
440 Views
ProblemHow to add two complex numbers which are entered at run time by the user using C program −SolutionA complex number is a number that can be a combination of real and imaginary parts.It is represented in the form of a+ib.ProgramFor example, let’s take the two complex numbers as (4+2i) and (5+3i) after adding the two complex numbers, the result is 9+5i. Live Demo#include struct complexNumber{ int realnumber, imaginarynumber; }; int main(){ struct complexNumber x, y, z, p; printf("enter first complex number x and y"); scanf("%d%d", &x.realnumber, &x.imaginarynumber); printf("enter second complex number z and p"); ... Read More
356 Views
Pascal's triangle is the representation of integers in the form of a triangle. One of the famous representations of it is with binomial equations. We can use combinations and factorials to achieve this.Constructing a Pascal triangleAll values outside the triangle are considered zero (0). The first row is 0 1 0 whereas only 1 acquire a space in Pascal’s triangle, 0s are invisible. The second row is acquired by adding (0+1) and (1+0). The output is sandwiched between two zeroes. The process continues till the required level is achieved.Programmatically, a Pascal triangle is defined as an array constructed by adding ... Read More