C Program for beginners
keywords: c program to subtract, c language to subtract, c program to minus, c++ program to minus or subtract, easy way to subtract, easy c program to subtract, , simplest program, simplest c or c++ program, easy program of c language, use c programming to hack, learn JavaScript, learn Perl, learn html, learn css, learn, algorithm, c program for kid, c program, c++ program, easy c program, c program, first lesson in c program, learn c programming in 1 hour, x byte lab, xbyte, xbytelab, ashiq dey, author ashiq, author dey, easy way write c program, how to write a c program, google, google love you, use google, best search engine google, make money with google, google friendly, google seo, code x ,codex.blospot.in, codex-lab.blogspot, c language, subtract, earn money, sexy, girl, top most hacker, panty, ebook for c program, ebook to learn c, c ebook, c++ ebook.
C Programming to “Subtract”
|
If you are new to C language then without wasting time Visit this link. Because if you learn from beginning then only it will be beneficial for you and it will not take more than half an hour to learn the basics.
A C/C++ program to add two numbers can be achieved through many ways. Here we showed only 4 of them. Like you we too don’t like boring so we explained each steps with friendly language which make learning enjoyable. Before heeding ahead you should know the basic keywords, variables,structure etc. If you are new to C Language you can know about them at this link. Still to make the learning process easy to understand, we explained about the program right below the code.
To know how to write and where to write the main structure of a C program visit this link.
To download application to write C/C++ program visit this link.
To get the list of all C programs for beginners visit this link.
|
Method 1
|
Sl. no.
|
Code
|
1
|
#include<stdio.h>
|
2
| main() |
3
|
{
|
4
| int x,y; |
5
| printf("Enter two no.: "); |
6
| scanf("%d%d",&x,&y); |
7
| printf("\n %d - %d = %d",x,y,x-y); |
6
| return 0; |
7
|
}
|
C is a case sensitive so everything should be as it is in the code, but within the “…” of printf function you can write with your choice
Explanation:
1. The first line of the program #include<stdio.h> is a preprocessor command, which tells a C compiler to include stdio.h (standard input output functions in the program from the library) file before going to actual compilation.
2. It is the main function where program execution begins.
3. Within the Braces we are going to write the program.
4. All the variable that we will use in the program have to be declared first in int
And in C after every line we have to put ‘;’ symbol to declare that the line ended.
5. printf is a function available in C which causes the message "Enter two no.:" to be displayed on the screen.
And \n is used to start a new line.
6. scanf function used to read the values of x,y (It will take input from user)
Notice the syntax carefully, most beginner makes mistake here only,
NOTE: There is no coma ‘,’ between %d%d and variables are written as ,&x and ,&y but in Printf function variables are written as ,x and ,y
7. Last printf is going to print the result, you can position the text as you wish see 2nd method for another style of displaying the text and result.
Here the formula is written within the printf function and this is not at all a good practice see 2nd method to write the formula separately.
8. return 0; terminates main()function and returns the value 0.
tags: c program to subtract, c language to subtract, c program to minus, c++ program to minus or subtract, easy way to subtract, easy c program to subtract, , simplest program, simplest c or c++ program, easy program of c language, use c programming to hack, learn JavaScript, learn Perl, learn html, learn css, learn, algorithm, c program for kid, c program, c++ program, easy c program, c program, first lesson in c program, learn c programming in 1 hour, x byte lab, xbyte, xbytelab, ashiq dey, author ashiq, author dey, easy way write c program, how to write a c program, google, google love you, use google, best search engine google, make money with google, google friendly, google seo, code x ,codex.blospot.in, codex-lab.blogspot, c language, subtract, earn money, sexy, girl, top most hacker, panty, ebook for c program, ebook to learn c, c ebook, c++ ebook.
Method 2
|
Sl. no.
|
Code
|
1
|
#include<stdio.h>
|
2
| main() |
3
|
{
|
4
| int x,y,subtract; |
5
| printf("Enter 1st no.: "); |
6
| scanf("%d",&x); |
7
| printf("Enter 2nd no.: "); |
8
| scanf("%d",&y); |
9
| subtract = x-y; |
10
| printf("\n Result = %d”,subtract); |
11
| return 0; |
12
|
}
|
C is a case sensitive so everything should be as it is in the code, but within the “…” of printf function you can write with your choice.
Explanation:
1. Here printf and scanf function are used twice to take the input from user separately.
2. subtract = x-y; is the formula for subtracting and here subtract is a variable and you can take the variable of your own choice and if you are scratching head to know why I have left spaces before and after ‘=’ the answer is it’s my style, you can write with or without spaces, but be careful in scanf function.
3. Line 10 of this method and line 7 of previous method does the same thing, but here only Result = xyz will be displayed the %d used in this printf function is associated with subtract and subtract is a variable which is equal to x-y.
tags: c program to display hello world, very first c progam, c++ program to print hello world, c++ c application to show hello world, simplest program, simplest c or c++ program, easy programm of c language, use c programming to hack, learn java script, learn Perl, learn html,learn css,learn, algorithm, c program for kid, c program, c++ program, easy c program, c program, first lesson in c program, learn c programming in 1 hour, x byte lab, byte, xbytelab, ashiq dey, author ashiq, author dey, easy way write c program, how to write a c program, google, google love you, use google, best search engine google, make money with google, google friendly, google seo, code x ,codex.blospot.in, codex-lab.blogspot, c language.
I think now you got the point, still if you have any doubt then please comment here or visit my Facebook page c++ for beginner at this link
Different method of writing this program
|
Sl. no.
|
Code
|
1
|
#include<stdio.h>
|
2
| main() |
3
|
{
|
4
| int x,y,subtract; |
5
| printf("Enter the no.: "); |
6
| scanf("%d%d",&x,&y); |
9
| subtract = x-y; |
10
| printf("\n %d - %d = %d”x,y,subtract); |
11
| return 0; |
12
|
}
|
Sl. no.
|
Code
|
1
|
#include<stdio.h>
|
2
| main() |
3
|
{
|
4
| int x,y,s; |
5
| printf("Enter the no.: "); |
6
| scanf("%d%d",&x,&y); |
9
| s=x-y; |
10
| printf("\n %d - %d = %d”x,y,s); |
11
| return 0; |
12
|
}
|
tags: c program to subtract, c language to subtract, c program to minus, c++ program to minus or subtract, easy way to subtract, easy c program to subtract, , simplest program, simplest c or c++ program, easy program of c language, use c programming to hack, learn JavaScript, learn Perl, learn html, learn css, learn, algorithm, c program for kid, c program, c++ program, easy c program, c program, first lesson in c program, learn c programming in 1 hour, x byte lab, xbyte, xbytelab, ashiq dey, author ashiq, author dey, easy way write c program, how to write a c program, google, google love you, use google, best search engine google, make money with google, google friendly, google seo, code x ,codex.blospot.in, codex-lab.blogspot, c language, subtract, earn money, sexy, girl, top most hacker, panty, ebook for c program, ebook to learn c, c ebook, c++ ebook.
c programming sample codes Program to calculate Area of a Polygon
ReplyDelete