Posts

Showing posts from March, 2018

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.