Saturday, 19 September 2020
Program to check whether the number is divisible by 5 or not.
Friday, 18 September 2020
A program that reads time in second and convert it into hours,minutes and seconds
Program to convert given number of days into year,week,day.
Monday, 14 September 2020
A program to find the quadrants of a given co-ordinates.
//program to find the quadrants of the coordinates//
#include<stdio.h>
int main()
{
int x,y;
printf("Enter the co-ordinates:");
scanf("%d %d",&x ,&y);
if(x>0&&y>0)
{
printf("Co-ordinates (%d,%d) lies in 1st quadrant",x,y);
}
if(x<0 y="">0)0>
{
printf("Co-ordinates (%d,%d) lies in 2nd quadrant",x,y);
}
if(x<0 p="" y="">0>
{
printf("Co-ordinates (%d,%d) lies in 3rd quadrant",x,y);
}
if(x>0&&y<0 p="">0>
{
printf("Co-ordinates (%d,%d) lies in 4th quadrant",x,y);
}
if(x=0&&y=0)
{
printf("Co-ordinates(%d,%d) lies in origin",x,y);
}
return 0;
}
OUTPUT:
Saturday, 12 September 2020
A Program to print given number in reverse order
Program to print given number in reverse order
Output
Variables Used:
- num: num is used to store the number given by the user.
- x: x is used to store num temporarily after finding modulus of num with 10 and dividing num by 10.
- rev: rev is used to store the reversed value of the given number (final output) whose value is initially 0.
- dummy: dummy is used to store the value of num just for showing the value of num in the output screen
Description
- Firstly we ask the value of num to the user.
- Then, we store the value of num in dummy just to use it at the last while printing the previous value of num.
- Then, if x value is greater than 0 we go through while loop
- In the first line inside while loop x = num % 10, x stores modulus of num after dividing it to 10.
- In the second line inside while loop rev = rev * 10 + x, here rev stores value after multiplying 10 with rev then adding x. likely it stores the final value.
- In the third line inside the while loop num = num/10, it divides num/10 and num stores int value of reminder.
- Lastly printf prints the final reversed value of given number.
working Module:
- firstly dummy stores the value of num then it goes to while loop and checks condition if num is greater than 0 or not. Here num 456 is greater than 0 so this condition returns true so it goes inside while loop. Compiler checks the first line of the block where the logic is x = num % 10 = 456%10 = 6. It calculates the modulus of num and gets the value as 6 and stores it in x variable then it goes to second line and the logic is rev = rev * 10 + x. In this logic variable x is treated as 6 just because x stores 6. Then it performs the calculation as rev = 0 * 10 + 6 = 6 ( rev is initially 0), now rev stores 6 then it goes to third line and checks the logic num = num/10. This logic is performed as num = 456/10 = 45 . Now num stores 45 (it doesn't store 45.6 because it's data type is int (integer)). Then again it goes to while loop and checks condition (num>0), yes num is 45 now and it is still greater so the condition returns true again. It goes to first line again and performs same task as before. this time x stores x = num % 10 = 45 % 10 = 5. Now compiler goes to second line and now rev stores rev = rev * 10 + x = 6 * 10 + 5 = 65. Then it goes to third line and now num stores num = num / 10 = 45/10 = 4. Now it again checks the condition inside while loop (num>0) yes num = 4 is greater than 0 which is true so it again goes inside while loop and read the first line x = num % 10 = 4%10 = 4. Then it goes to second line rev = rev * 10 + x = 65 * 10 + 4 = 654. Then it compiler checks third line and calculate num as num = num/10 = 4/10 = 0. again it goes to while loop and checks condition (num>0) but this time it returns false because num is smaller than 0. Now finally rev stores 654 which is the reversed value of 456 then we print it using printf function.
Thursday, 10 September 2020
Program to print the fibonacci series.
Program to print Fibonacci Number Series
Wednesday, 9 September 2020
Program to check whether the number is armstrong or not.
OUTPUT:
DESCRIPTION:
USED VARIABLE:
Making a simple calculator using C
Program to make calculator using C
![]() |
Description: In this program,we ask the user to input two numbers along with the operator which they want to do.And using the switch case function, we calculate the value as user wants. |
Tuesday, 8 September 2020
Alternative method to find the multiplication table.
Program to find the multiplication table of a number
Program to check weather the number is palindrome or not.
Monday, 7 September 2020
A program to compare three numbers and display the biggest number.
Sunday, 6 September 2020
Program to check weather the given number is odd or even.
Program to find the factorial of a number
Program to check weather the number is odd or even
/*Program to check weather the number is odd or even*/
#include <stdio.h>
int main ()
{
int a;
printf("Enter the number:");
scanf("%d", &a);
if (a%2==0)
{
printf("the number is even");
}
else
{
printf("the number is odd");
}
return 0;
}
OUTPUT:
DESCRIPTION:
Saturday, 5 September 2020
Program to find the sum of two numbers
/*program to find the sum of two numbers*/
#include<stdio.h>
int main()
{
float a,b,sum;
printf("Enter two numbers:");
scanf("%f %f",&a ,&b);
sum=a+b;
printf("%.2f",sum);
return 0;
}
OUTPUT:
Description:
Program to calculate Simple Interest
/*program to compute the simple interest*/
#include<stdio.h>
int main()
{
float P,T,R,INTEREST;
printf("Enter the principal:");
scanf("%f",&P);
printf("Enter the time:");
scanf("%f",&T);
printf("Enter the rate:");
scanf("%f",&R);
INTEREST=(P*T*R)/100;
printf("The interest amount is %.1f",INTEREST);
return 0;
}
OUTPUT
Description:
Program to calculate circumference of the circle
/*Program to find circumference of the circle*/
#include <stdio.h>
#define PI 3.14
int main()
{
float r,circumference;
printf("Enter the radius of the circle:");
scanf("%f",&r);
circumference=2*PI*r;
printf("The circumference of the circle is %.2f",circumference);
return 0;
}
OUTPUT
Enter the radius of the circle: 2.7
The circumference of the circle is 16.96
Description:
Program to calculate area of the rectangle
/* Program to calculate area of rectangle*/
#include<stdio.h>
int main(){
int Area,Length,Breadth;
Length=20;
Breadth=10;
Area=Length*Breadth;
printf("The area is %d", Area);
return 0;
}
Output:
Description:
Program to print Hello World in C
/* A basic C program to print"Hello World"*/
#include<stdio.h>
int main()
{
printf("HELLO WORLD!");
return 0;
}
OUTPUT
Description
Types of error in C
1.Syntax Error
It is the error in programs grammatical rule or in writing format.This type of error is detected by translator during translation so,it is easier to correct.2.Semantic(Logical error)
It is an error(bug) in the concept or the logic of the program like formula mistakes.3.Run-time error
It is an error that is generated while the program is being executed.For example: Memory leak.Advantages and Disadvantages of C
Advantages
-Easier to interact with hardware.-Easy to learn.
-Compact and efficient.
Dis-advantages
-Doesnot contain runtime checking.-No strict data type checking.
-As the program extends it is very difficult to fix the bugs.
What are the features of c?
1. One of the reasons of C's popularity is its portability.
2.It is faster and more efficient than other languages.3.It is suitable for the structured programming that means problem can be solved in terms of modules or blocks.
4.C is rich in its library function.
What is C?
C is a middle level programming language developed and designed by Dennis Ritchie at AT & T's Bell Laboratories of USA in 1970s. It is reliable,simple and easy to use.
Search This Blog
-
▼
2020
(24)
-
▼
September
(24)
- Program to check whether the number is divisible b...
- A program that reads time in second and convert i...
- Program to convert given number of days into year,...
- A program to find the quadrants of a given co-ordi...
- A Program to print given number in reverse order
- Program to print the fibonacci series.
- Program to check whether the number is armstrong ...
- Making a simple calculator using C
- Alternative method to find the multiplication table.
- Program to find the multiplication table of a number
- Program to check weather the number is palindrome...
- A program to compare three numbers and display th...
- Program to check weather the given number is odd o...
- Program to find the factorial of a number
- Program to check weather the number is odd or even
- Program to find the sum of two numbers
- Program to calculate Simple Interest
- Program to calculate circumference of the circle
- Program to calculate area of the rectangle
- Program to print Hello World in C
- Types of error in C
- Advantages and Disadvantages of C
- What are the features of c?
- What is C?
-
▼
September
(24)
Labels
About Me
Program to print weather the number is happy or not.
#include <stdio.h> #include <math.h> int main () { int i , j , num , temp , sum = 0 ; printf ( "Enter number\n...

















