Posts

Showing posts from 2018

Write a program to input three digit number and check number is palindrome or not.

Image
Program in C Language  About Program :-  Here we will learn C Language through a basics. Programming in C is a very easy if you understand its logic. Here we input 3 number and check its palindrome or not.            First we use printf for print a messege to user and ask three number and we take input by using scanf and finally after this logic section. First we break its digit like 235 to 2,3,5 and check 1st and 3rd are equal or not.        If 1st and 3rd digit are equal then enter number is palindrome or not. So let's see code..... #include<stdio.h> #include<conio.h> void main() { int n,a,b; clrscr(); printf("Enter a 3 digit number="); scanf("%d",&n); a=n/100; b=n%10; if(a==b)   printf("\nThis is Palindrome "); else   printf("\nThis is not Palindrome "); getch(); } OUTPUT Enter a 3 digit number=232 This is Palindrome           ...

Write a program to check age of any student is teen age or not.

Image
Programming in C Language... About program -- In this program we input age of a student and check he is teen ager or not. In details , If age is greater and equal to 13 and less than and equal to 19 then we can say , student is teen ager and if this condition is false then we print that student is not teen ager. #include<stdio.h> #include<conio.h> void main() { int a; clrscr(); printf("Enter age of student="); scanf("%d",&a); if(a>=13 && a<=19) printf("\nThis is teen ager"); else printf("\nThis is not teen ager"); getch(); } OUTPUT Enter age of student=19 This is teen ager                  Or Enter age of student=23 This is not teen ager Write a program to input two digit number and check number is palindrome or not. Write a program to input speed of Royal Enfield and check it's running at economic speed or not. Write a program to input length and width of a shape and find sha...

Write a program to input two digit number and check number is palindrome or not.

Image
ABOUT PROGRAM In this program we input a two digit number and check number is palindrome(a number which read by both side) or not. For this program we use if else statement and you should knowledge of some basic conditional statements program. So check last program.            First,we should 1st digit by using division and 2nd digit by using modular and at the end we check that both digits or equal or not. If both are equal then we print this is palindrome or not.  #include<stdio.h> #include<conio.h> void main() { int n,a,b; clrscr(); printf("Enter two digit number="); scanf("%d",&n); a=n/10; b=n%10; if(a==b)  printf("\nThis is Palindrome"); else  printf("\nNot Palindrome number"); getch(); } OUTPUT  Enter two digit number=66 This is Palindrome                     OR Enter two digit number=65 Not Palindrome number Related Examples...

Write a program to input speed of Royal Enfield and check it's running at economic speed or not.

Image
About Program  In this program we input a speed of Royal Enfield or any bike or car anything. In short we input a speed and check what is status of its speed means, is bike at economic speed???         For this program, logic is if speed less than 80 then we can say bike run at economic speed else this condition is false then we can say bike not run at economic speed. Let's Begin --  #include<stdio.h> #include<conio.h> void main() { int s; clrscr(); printf("Enter speed of Royal Enfield="); scanf("%d",&s); if(s<80)  printf("\nRunning at economic speed"); else  printf("\nNot Running at economic speed "); getch(); } OUTPUT   Enter speed of Royal Enfield=76 Running at economic speed                          OR Enter speed of Royal Enfield=84 Not Running at economic speed Related Examples  Write a program to input length and ...

Write a program to input length and width of a shape and find shape is square or rectangle.

Image
About Program In this program we input length and width of a shape and check what kind of shape.    To understand this program you should knowledge of some basic conditional statements (if-else) program. Some Basic conditional statements programs are below.    If length and width of shape is same then we print Square else print Rectangle. #include<stdio.h> #include<conio.h> void main() { int l,w; clrscr(); printf("Enter length and width of shape="); scanf("%d%d",&l,&w); if(l==w)  printf("\nShape is Square"); else  printf("\nShape is Rectangle"); getch(); } OUTPUT Enter length and width of shape=5 5 Shape is Square                   OR Enter length and width of shape=5 6 Shape is Rectangle Related Examples  Write a program to input sell price and cost price and find transaction is profit or loss.  Write a program to input a number and check number ...

Write a program to input sell price and cost price and find transaction is profit or loss.

Image
About Program  In this program we input sell price and cost price of a product and calculate what happened in this transaction, profit or loss. For this we need a condition which describe in if block. If sell price is greater than cost price then transaction is profit else loss. #include<stdio.h> #include<conio.h> void main() { int sp,cp; clrscr(); printf("Enter sell price and cost price="); scanf("%d%d,&sp,&cp); if(sp>cp)  printf("\nTransaction in Profit"); else   printf("\nTransaction in Loss"); getch(); } OUTPUT   Enter sell price and cost price=500 400 Transaction in Profit               OR Enter sell price and cost price=400 500 Transaction in Loss Related Examples  Write a program to input age of any person and check he is eligible for voting or not. Write a program to input a number and check number is odd or even. Write a program to input two number and fin...

Write a program to input age of any person and check he is eligible for voting or not.

Image
In this program we input age of any person and check he is eligible for voting or not means we input a number by user and check number is greater than and equal to 18 then he is eligible for voting else not. So let's start #include<stdio.h> #include<conio.h> void main() { int a; clrscr(); printf("Enter age of person="); scanf("%d",&a); if(a>=18)   printf("\nEligible for voting"); else   printf("\nNot eligible for voting"); getch(); } RELATED EXAMPLES  Write a program to input age of an employee and check he is retired or working . Write a program to input a number and check number is odd or even. Write a program to input two number and find smallest number .   Write a program to input two number and find highest number.   Share and Comment.  Follow for recently updates.

Write a program to input age of an employee and check he is retired or working.

Image
In this program we input age of an employee and check his status means he is Working or Retired.     For this program we input an employee age by user and check if age is greater than 60 then we print Retired else Print Working.    This is conditional statements program. For learn this program you should basic knowledge of conditional statements. Learn basic see if-else programs. #include<stdio.h> #include<conio.h> void main() { int a; clrscr(); printf("Enter employee age="); scanf("%d",&a); if(a>=60)  printf("\nRetired"); else  printf("\nWorking"); getch(); } OUTPUT  Enter employee age=65 Retired              OR Enter employee age=55 Working Related Examples Write a program to input an year and check year is leap or not.  Write a program to input a number and check number is odd or even. Write a program to input two number and find smallest number .  ...

Write program to input year and check year is leap or not.

Image
In this program we input an year and check year is leap or not, that means we input a year by user and then he find Leap year if condition is true else Not leap year.    As we know leap year means that year which divided by 4. In program we write a condition that if year fully divided by 4 then Leap year else Not leap year.    Let's Begin -- #include<stdio.h> #include<conio.h> void main() { int y; clrscr(); printf("Enter a year="); scanf("%d",&y); if(y%4==0)  printf("\nLeap year"); else  printf("\nNot leap year"); getch(); } OUTPUT   Enter a year=2001 Not leap year                     OR Enter a year=2016 Leap year Related Examples  Write a program to input a number and check number is odd or even. Write a program to input two number and find smallest number .  Write a program to input two number and find highest number.  ...

Write program to input a number and check number is odd or even.

Image
In this program we input a number and check number is odd or even means if number is devide by 2 then we can say number is even number else odd number. For learn this program you should knowledge of some simple conditional programs. That's link below. #include<stdio.h> #include<conio.h> void main() { int n; clrscr(); printf("Enter a number="); scanf("%d",&n); if(n%2==0)   printf("Even number"); else   printf("Odd number"); getch(); } OUTPUT  Enter a number=5 Odd number               Or Enter a number=4 Even number Related Examples  Write a program to input two number and find the highest number. Write a program to input two number and find the smallest number. Write a program to input a number and check number is positive,negative or nuteral.  Write a program to input a number and check number is negative or not . Write a program to input a number and check number is positiv...

Write a program to input two number and find smallest number.

Image
In this program we input two number and check which number is smallest. For this, we give a condition As:- If 1st number is smallest then print 1st number else 2nd number is smallest and print 2nd number. #include<stdio.h> #include<conio.h> void main() { int a,b; clrscr(); printf("Enter 1st number="); scanf("%d",&a); printf("Enter 2nd number="); scanf("%d",&b); if(a<b) printf("\n1st number is smallest"); else printf("\n2nd number is smallest"); getch(); } OUTPUT   Enter 1st number=7 Enter 2nd number =10 1st number is smallest Related Examples  Write a program to input a number and check number is positive or not. Write a program to input a number and check number is negative or not.  Write a program to input a number and check number is positive,negative or nuteral. Write a program to input two number and find highest number.  Follow for recently updates ,Share...

Write a program to input two number and find highest number.

Image
In this program we input two number and check which number is highest. For this, we give a condition As:- If 1st number is highest then print 1st number else 2nd number is highest and print 2nd number. #include<stdio.h> #include<conio.h> void main() { int a,b; clrscr(); printf("Enter 1st number="); scanf("%d",&a); printf("Enter 2nd number="); scanf("%d",&b); if(a>b) printf("\n1st number is highest"); else printf("\n2nd number is highest"); getch(); } OUTPUT   Enter 1st number=9 Enter 2nd number =7 1st number is highest Related Examples  Write a program to input a number and check number is positive or not. Write a program to input a number and check number is negative or not.  Write a program to input a number and check number is positive,negative or nuteral.   Follow for recently updates ,Share and Comment. 

Write a program to input a number and check number is positive,negative or nuteral.

Image
In this program input a number and check number is positive, negative or nuteral. If number is greater than Zero then print positive , if less than zero then print negative and if both condition false then print nuteral. #include<stdio.h> #include<conio.h> void main() { int n; clrscr(); printf("Enter a number="); scanf("%d",&n); if(n>0) printf("Positive number"); else if(n<0) printf("Negative number"); else printf("Nuteral"); getch(); } OUTPUT  Enter a number=4 Positive number                Or Enter a number=-4 Negative number                Or Enter a number=0 Nuteral Related Examples  1. Write a program to input a number and check number is positive or not. 2. Write a program to input a number and check number is negative or not.  Follow for recently updates on Google+ or subscribe. 

Write a program to input a number and check number is negative or not.

Image
In this program we input a number and check number is negative or not means if number is less than Zero then number is negative or not. #include<stdio.h> #include<conio.h> void main() { int n; clrscr(); printf("Enter a number="); scanf("%d",&n); if(n<0) printf("\nNegative number"); else printf("Not negative number"); getch(); } OUTPUT  You can follow me on Google+. Subscribe for recently updates. 

Write a Program to input a number and check number is positive or not.

Image
In this program we input a number and check number is positive or not. If number is greater than Zero, then number is positive. #include<stdio.h> #include<conio.h> void main() { int n; clrscr(); printf("Enter a number="); scanf("%d",&n); if(n>0) printf("Positive number"); else printf("Not positive number"); getch(); } Follow for recently updates. 

Program to input three number and print their Reverse.

Image
In this program we input three numbers and print their Reverse. First we find 1st digit by (n/100), 2nd digit by(n/10)%10 and 3rd digit by (n%10). Then finally we add a program logic. #include<stdio.h> #include<conio.h> void main() { int n,d1,d2,d3,r=0; clrscr(); printf("Enter three digit number="); scanf("%d",&n); d1=(n/100); d2=(n/10)%10; d3=n%10; r=(d3*100)+(d2*10)+d1; printf("\nReverse of number=%d",r); getch(); } OUTPUT 

Program to input three number and print their sum of digits in C.

Image
In this program we input three numbers and print their sum of digit. First we find 1st digit by (n/100), 2nd digit by(n/10)%10 and 3rd digit by (n%10). Then finally sum of digits. #include<stdio.h> #include<conio.h> void main() { int n,d1,d2,d3,s=0; clrscr(); printf("Enter three digit number="); scanf("%d",&n); d1=(n/100); d2=(n/10)%10; d3=n%10; s=d1+d2+d3; printf("\nSum of digits=%d",s); getch(); } OUTPUT 

Program to input two digit number and print their Reverse.

Image
In this program input two digit number and print the sum of its digits. For this we find 1st digit by number/10 and 2nd digit by n%10 . In the end we multiply 2nd number to 10 and add 1st number. #include<stdio.h> #include<conio.h> void main() { int n,d1,d2,r=0; clrscr(); printf("Enter two digit number="); scanf("%d",&n); d1=n/10; d2=n%10; r=(d2*10)+d1; printf("\nReverse of number=%d",r); getch(); } OUTPUT 

Program to input two digit number and print Sum of its digits.

Image
In this program input two digit number and print the sum of its digits. For this we find 1st digit by number/10 and 2nd digit by n%10.  #include<stdio.h> #include<conio.h> void main() { int n,d1,d2,s=0; clrscr(); printf("Enter two digit number="); scanf("%d",&n); d1=n/10; d2=n%10; s=d1+d2; printf("\nSum of digits=%d",s); getch(); } OUTPUT 

Program to input two number and print their values after interchange(Swap) without using third value.

Image
/* Program to swap two number in C */ #include<stdio.h> #include<conio.h> void main() { int a,b; clrscr(); printf("Enter first number="); scanf("%d",&a); printf("Enter second number="); scanf("%d",&b); a=a+b; b=a-b; a=a-b; printf("\nFirst number=%d",a); printf("\nSecond number=%d",b); getch(); } OUTPUT  Note: If any problems in this program please comment and never forget to Share. Follow for recently updates.

Program to input two numbers and print their values after interchange(Swap) using third value.

Image
#include<stdio.h> #include<conio.h> void main() { int a,b,c=0; clrscr(); printf("Enter first number="); scanf("%d",&a); printf("Enter second number="); scanf("%d",&b); c=a; a=b; b=c; printf(\nFirst number=%d",a); printf("\nSecond number=%d",b); getch(); } OUTPUT Note:- If any problem in this program please comment and never forget to share.

Program to input three number and calculate their Average.

Image
#include<stdio.h> #include<conio.h> void main() { int a,b,c,m=0; clrscr(); printf("Enter three number="); scanf("%d%d%d",&a,&b,&c); d=(a+b+c)/3; printf("Average=%d",d); getch(); } OUTPUT  Note:- If you want to calculate floating value (value which contains point) or fractional value ,you can use "float " and "%f" replace to "int " and "%d". If you want to calculate both use "double".

Program to input sell price and cost price and calculate Profit.

Image
/*Program to calculate Profit */ #include<stdio.h> #include<conio.h> void main() { int sp,cp,p=0; clrscr(); printf("Enter sell price="); scanf("%d",&sp); printf("Enter cost price="); scanf("%d",&cp); p=sp-cp; printf("Profit=%d",p); getch(); } OUTPUT 

Program to input length and width of a rectangle and print their area and perimeter in C.

Image
In this program we input length and width of a rectangle and print Area and Perimeter. 1st we input two number as length and width , after then we use Area and Perimeter formula in program logic. At last we print Area and Perimeter as Output. /*Program to calculate area and perimeter of rectangle*/ #include<stdio.h> #include<conio.h> void main() { int l,w,a=0,p=0; clrscr(); printf("Enter length="); scanf("%d",&l); printf("Enter width="); scanf("%d",&w); a=l*w; p=2*(l+b); printf("Area=%d",a); printf("\nPerimeter=%d",p); getch(); } OUTPUT  If any problems or suggestions in program please comment and share your programmer friends.  Follow for recently updates.   Related Examples  Write a program to input two number and print their addition.  Write a program to input two number and print their subtraction.  Write a program to input two number and print their multiplicati...

Program to input distance in km and calculate into meter.

Image
About this program      In this program we input a value in km and Convert into meter. #include<stdio.h> #include<conio.h> void main() { long int km,m; clrscr(); printf("Enter distance in km="); scanf("%d",&km); m=1000*km; printf("Distance in m=%d",m); getch(); } OUTPUT  Explanation : 1st step of program we use stdio.h header file because we'll use printf(); and scanf(); in this program and conio.h header file use because we'll use clrscr(); and getch(); . After this we use void main for open brace { . Main function does not return a value so we use void. This is almost same in many programs.        Then we declare variable as km and define its type as long int. Then use clrscr(); , printf and print a message for user after it we'll use scanf(); to input a number by user. We know 1km=1000m ,so we write logic and print their value by printf. At last we use getch(); for see output screen while we in...

Program to input two number and print their multiplication in C.

Image
In this program we input two number and find the multiplication. For this 1st we input a number and then 2nd number or if you want to input both in once, it's depend on you. So let's begin /*Program to multiplicate two number*/ #include<stdio.h> #include<conio.h> void main() { int a,b,m=0; clrscr(); printf("Enter 1st number="); scanf("%d",&a); printf("Enter 2nd number="); scanf("%d",&b); m=a*b; printf("Multiplication=%d",m); getch(); } OUTPUT Note:- If you want to calculate floating value then you can use "float",for both use "double" replace "int". Related Examples  Write a program to input two number and print their sum or addition . Write a program to input two number and print their subtraction .  Share and Comment and Follow for recently updates. You can follow me on "Google+".

Program to input two number and print their subtraction in C.

Image
In this program we input two and print their subtraction. This is 3rd program of C including "Hello World". /*Program to subtract two number*/ #include<stdio.h> #include<conio.h> void main() { int a,b,s=0; clrscr(); printf("Enter 1st number="); scanf("%d",&a); printf("Enter 2nd number="); scanf("%d",&b); s=a-b; printf("Subtraction=%d",s); getch(); } OUTPUT Note:- If you want to calculate floating value then you can use "float",for both use "double" replace "int". For more updates follow on "Google+". Related Examples  1. Write a program to input two number and print their sum.  2 .Write a program to input two number and print their multiplication. 

Program to input two numbers and print their sum in C.

Image
In this program we input two number and print their sum. For this we have print a message for user by printf and input a number by using scanf. After this process we write program logic and print this as final output. /*Program to add two number*/ #include<stdio.h> #include<conio.h> void main() { int a,b,s=0; clrscr(); printf("Enter 1st number="); scanf("%d",&a); printf("Enter 2nd number="); scanf("%d",&b); s=a+b; printf("Sum=%d",s); getch(); } OUTPUT Related Examples  1. Write a program to input two number and print their subtraction.  2. Write a program to input two number and print their multiplication.  Follow for recently updates. Share and Comment.