Posts

C Program To Check Whether The Number Is Positive Or Negative

Image
                                        C Program To  Check Whether The Number Is Positive Or Negative In this example, you will learn to  Find  Whether The Number Is Positive Or Negative Example 1 : number = 10 number is positive Example 2 : number = -10 number is negative Formula To C heck Whether The Number Is Positive Or Negative :-  if (num > 0)         print positive     else         print negative How Program Works ?? if (num > 0) Condition Check Whether The Number Is Positive Or Negative . if num is greater than 0 it return Positive. else num is less than 0 it return Negative . Logic ?? Number Greater Than 0 Means It Positive Number. Number Less Than 0 Means It Negative Number. Code For  " C heck Whether The Number Is Positive Or Negative ". /* Author --> HARSH PATEL */ #include ...

C Program To Find Area Of Rectangle

Image
  C Program To  Find Area Of Rectangle In this example, you will learn to  Find Area Of Rectangle Using int And Float. Example 1 Using int : width=10, length=20; Then , Area = 200 Example 2 Using float : width=100.5, length=50.5; Then , Area = 5075.250000 Formula To Find  Area Of Rectangle :- Area = Width * Length How Program Works ?? Program Calculate  Area = Width * Length Logic ?? Input  Width  And  Length Calculate  Area = Width * Length Print Area  Code For  " Find  Area Of Rectangle". Using int /* Author --> HARSH PATEL */ #include<stdio.h> int main() { int width,length,area; printf("Enter Width : "); scanf("%d",&width); printf("Enter length : "); scanf("%d",&length); area = width * length; printf("Area Of Rectangle = %d",area); } Output-1 Enter Width : 10 Enter length : 20 Area Of Rectangle = 200 Output-2 Enter Width : 100 Enter length : 23 Area Of Re...

C Program To Find Factors Of A Number

Image
  C Program To  Find Factors Of A Number In this example, you will learn to  Find Factors Of A Number Example : Enter Any Number To Find Factors 12 Factors Of The Given Number Are = 1, 2, 3, 4, 6, 12 How Program Works ?? Input number from user. Store it in variable say number. Run a loop Example (i = 1; i <= Number; i++) To check factor if(number % i == 0) then i is a factor of num. If i is a factor of number then print i . Logic ?? Factor of any number is a  number which exactly divides the number into a whole number without any remainder. Code For  " Find Factors Of A Number ". /* Author --> HARSH PATEL */ #include <stdio.h> int main() { int i, Number; printf("\nEnter Any Number To Find Factors \n"); scanf("%d", &Number); printf("\nFactors Of The Given Number Are = \n"); for (i = 1; i <= Number; i++) { if(Number%i == 0) { printf(" %d ", i); } } return 0; } Output-1 E...

C Program To Find Division Of Two Numbers

Image
  C Program To Find Division  of two numbers In this example, you will learn to calculate Division Of Two Numbers Using printf() And scanf() Functions. How Program Works ?? This Program Can Be Run By Two Ways (1) Using printf() Or  (2) Using scanf()  We Use (/) Operators To Calculate Division If You Entered a=10 And B=5 Then It Represent As div   = a / b; where a = 10 , b = 5 And Answers Which Div = 2; Code For  " Division Of Two Numbers  ", Using   printf() Function. /* Author --> HARSH PATEL */ #include<stdio.h> void main() { int a = 10; //You Can Add Any Number int b = 5; //You Can Add Any Number int c = a / b; //Now int C Calculate division Of Two Numbers Which You Added On a & b printf("Division Of Two Numbers = %d",c); } OUTPUT For "Division  Of Two Numbers  ", Using   printf()     Function. Division Of Two Numbers = 2 Now Using   scanf()  Function . N...

C Program To Find Multiplication Of Two Numbers

Image
  C Program To Find  multiplication of two numbers In this example, you will learn to calculate Multiplication Of Two Numbers Using printf() And scanf() Functions. How Program Works ?? This Program Can Be Run By Two Ways (1) Using printf() Or  (2) Using scanf()  If You Entered a=10 And B=10 Then We Use (*) Asterisk Operators To Calculate Multiplication It Represent As multiplication   = a * b; where a = 10 , b = 10 And Answers Which Multiplication  = 100; Code For  "  multiplication  Of Two Numbers  ", Using   printf() Function. /* Author --> HARSH PATEL */ #include<stdio.h> void main() { int a = 10; //You Can Add Any Number int b = 10; //You Can Add Any Number int c = a * b; //Now int C Calculate multiplication Of Two Numbers Which You Added On a & b printf("Multiplication Of Two Numbers = %d",c); } OUTPUT For " Multiplication Of Two Numbers  ", Using   p...

C Program To Find Subtraction Of Two Numbers

Image
  C Program To Find  subtraction of two numbers In this example, you will learn to calculate Subtraction Of Two Numbers Using printf() And scanf() Functions. How Program Works ?? This Program Can Be Run By Two Ways (1) Using printf() Or  (2) Using scanf()  If You Entered a=30 And B=20 Then It Represent As sub   = a - b; where a = 30 , b = 20 And Answers Which Sub = 10; Code For  " Subtraction Of Two Numbers  ", Using   printf() Function. /* Author --> HARSH PATEL */ #include<stdio.h> void main() { int a = 50; //You Can Add Any Number int b = 40; //You Can Add Any Number int c = a - b; //Now int C Calculate subtraction Of Two Numbers Which You Added On a & b printf("Subtraction Of Two Numbers = %d",c); } OUTPUT For " Subtraction Of Two Numbers  ", Using   printf()     Function. Subtraction Of Two Numbers = 10 Now Using   scanf()  Function . Now Code For  " Find...

C Program To Find Sum Of Two Numbers

Image
  C Program To Find sum of two numbers In this example, you will learn to calculate Sum Of Two Numbers Using printf() And scanf() Functions. How Program Works ?? This Program Can Be Run By Two Ways (1) Using printf() Or  (2) Using scanf()  If You Entered a=10 And B=15 Then It Represent As sum = a + b; where a = 10 , b = 15 And Answers Which Sum = 25; Code For  " Find Sum Of Two Numbers  ", Using   printf() Function. /* Author --> HARSH PATEL */ #include<stdio.h> void main() { int a = 10; //You Can Add Any Number int b = 20; //You Can Add Any Number int c = a + b; //Now int C Calculate Sum Of Two Numbers Which You Added On a & b printf("Sum Of Two Numbers = %d",c); } OUTPUT For  Sum Of Two Numbers  ", Using   printf()    Function. Sum Of Two Numbers = 30 Now Using  scanf()  Function . Now Code For  " Find Sum Of Two Numbers  ", Using   scanf()  Funct...