Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by Mandalika
409 articles
How to print a one-month calendar of user choice using for loop in C?
The logic to print a one-month calendar is as follows −for(i=1;i
Read MoreHow to calculate the volume of a sphere using C programming language?
The volume of sphere is nothing but the capacity of the shape.Volume of a sphere formula is −$$V\:=\:\frac{4}{3}\Pi\:r^{3}$$AlgorithmStep 1: Enter radius of sphere at runtime Step 2: Apply the formula to variable Volume=(4/3)*3.14*rad*rad*rad Step 3: print the volume Step 4: stopProgram 1#include int main(){ float vol; int rad; rad=20; vol=((4.0f/3.0f) * (3.1415) * rad * rad * rad); printf("the volume of a sphere is %f", vol); return 0; }Outputthe volume of a sphere is 33509.335938Program 2Following is an example to find Volume and Surface Area of Sphere −#include #include ...
Read MoreC program on calculating the amount with tax using assignment operator
ProblemWrite a C Program to enter the amount in dollars and then display the amount by adding 18% as tax.SolutionLet’s consider the restaurant person adding 18% tax to every bill of the customer.The logic applied to calculate tax is −value=(money + (money * 0.18));The money should be multiplied by 18% and add to the money, then the restaurant person can receive the amount from a customer with tax.Example#include int main(){ float money, value; printf("enter the money with dollar symbol:"); scanf("%f", &money); value=(money + (money * 0.18)); printf("amount after adding tax= %f", value); return 0; ...
Read MoreWrite C program to calculate balance instalment
ProblemWrite a C program to calculate a balance installment that is to be paid after every month for a particular loan amount (with interest).SolutionFollowing is the formula to calculate interest when the loan amount is given −i=loanamt * ((interest/100)/12);Following calculation gives amount with interest −i=i+loanamt; firstmon=i-monthlypayment; //first month payment with interest i=firstmon * ((interest/100)/12);Program#include int main(){ float loanamt, interest, monthlypayment; float i, firstmon, secondmon; printf("enter the loan amount:"); scanf("%f", &loanamt); printf("interest rate:"); scanf("%f", &interest); printf("monthly payment:"); scanf("%f", &monthlypayment); //interest calculation// i=loanamt * ((interest/100)/12); //amount with interest i=i+loanamt; ...
Read MoreWrite a C program to perform 3X3 matrix operations
ProblemEnter any 9 numbers at runtime and add the numbers in a row, column, and diagonal wise by using C Programming languageAlgorithmStep 1: Declare 9 variables Step 2: enter 9 numbers at runtime Step 3: store the numbers in 3 X 3 matrix form //x y z p q r a b c Step 4: Do row calculation: add all the numbers in a row and print // (x+y+z), (p+q+r), (a+b+c) Step 5: Do column calculation: add all the numbers in a Column and ...
Read MoreDifferentiate the modulo and division by using C Programming language?
Modulo − Represents as % operator. And gives the value of the remainder of an integer division.Division − represents as / operator. And gives the value of the quotient of a division.Program 1#include int main(){ int a, b, c; printf("enter a, b, c values:"); scanf("%d%d%d, &a, &b, &c); printf("a/b=%d a%b=%d", a/b, a%b); printf("(a+10)%b=%d (a+10)/b=%d", (a+10)%b, (a+10)/b); }Outputenter a, b, c values:2 4 6 a/b=0 ab=2 (a+10)b=0 (a+10)/b=3Program 2Applying pointer variables to perform modulo and division operation −#include void main(){ //Declaring pointers and variables// int num1, num2; int *p1, *p2; p1=&num1; p2=&num2; ...
Read MorePrinting the numbers in reverse order using Division and modulo operators using C
ProblemHow to print the given two-digit number in reverse order with the help of division and Modulo operator using C programming language?SolutionSo far, we had seen how to reverse the string using string function and without string function. Now let’s see how to reverse the two-digit number without using the predefined function.The logic we use to reverse the number with the help of operators is −int firstno=number%10; //stores remainder int secondno=number/10;// stores quotientThen print the first number followed by the second number then you will get the reverse number for the given number.Program 1In this example, we will take a ...
Read MoreUsing iterative function print the given number in reverse order in C language
ProblemHow to print the given in reverse order with the help of iterative function i.e., while loop using C programming language?SolutionSo far, we had seen how to reverse the string using string function and without string function, now let’s see how to reverse a number without using predefined function −AlgorithmInput − give a number at runtimeStep 1: Declare the variable number, reverse Step 2: Initialize reverse= 0 Step 3: while number>0 (a) reverse=reverse*10 + number%10; reverse = reverse*10 + num%10; (b) Divide number by 10 Step ...
Read MoreCheck the number is Armstrong or not using C
ProblemHow to check whether the given number is an Armstrong number or not using C Programming language?SolutionArmstrong number is the number that is equal to the sum of cubes of its digits.Syntaxpqrs………=pow(p, n)+pow(q, n)+pow(r, n)+……….For example, 153, 371, 1634, etc., are Armstrong numbers.153=1*1*1 + 5*5*5 + 3*3*3 =1+125+27 =153 (Armstrong number)Program#include int main(){ int number, remainder, total=0, temp; printf("enter the number="); scanf("%d", &number); temp=number; while(number>0){ remainder=number%10; total=total+(remainder*remainder*remainder); number=number/10; } if(temp==total) printf("This number is Armstrong number"); else ...
Read MoreHow to print Floyd’s triangle (of integers) using C program?
Floyd's triangle is a right-angle triangle of consecutive numbers, starting with a 1 in the top left corner −For example,1 2 3 4 5 6 7 8 9 10Example 1#include int main(){ int rows, i,j, start = 1; printf("Enter no of rows of Floyd's triangle :"); scanf("%d", &rows); for (i = 1; i
Read More