In this course we will learn everything about “C” language. After reading the upper definition of “C” language you know that this is very important language that’s why I’ll try to make this course interesting and easy to understand as possible. In this course we will make some Games in “C” language.
What is “C” language?
“C” is programming language which is the mostly used by programmers. There are many programming languages Java, VB and many other languages but “C” is a very famous and powerful programming language. You can develop any desktop software using “C” language. Many software developed in “C” language like VLC media player, Photoshop, Coral draw and many other software. So this is a very good programming language. You can create any type of software using this language. “C” language is base of every successful programmer. If you are successfully learned “C” then you will be able to learn every type of language.
Brief history of “C” language.
“C” is a popular high level language. It was developed by Dennis Ritchie at At&T Bell Laboratories in 1972. C language was derived for of an earlier programming language called B. The “C” language basically developed for writing programs under UNIX operating system. The flexibility of “C” made it famous in the market. The earlier version of “C” was known as K&R (Kernighan and Rirchie). The American National Standard Institute (ANSI) developed the standard version of language. This new version of the language provided many new functions which were not available in the earlier versions.
Start learning
Making first program
Write the program below in your compiler. You can use Turbo C++ or you can use Dev C++.
#include<stdio.h>
#include<conio.h>
Void main(){
Printf(“azeemIT.blogspot.com”);
}
Output: azeemIT.blogspot.com
Detail: “#include<stdio.h>” and” #include<conio.h>” are the header file or libraries of “C”. “Void main()” is a function which is used for start a program the actual written in this function. Printf() is built -in keyword provided by “C” for print something (which is written in the double quotes) on the screen. And semicolon “;” is called statement terminator which is used for ending statement. This program is the basic structure of “C” program. You must have to write these line of codes before writing your actual program.
Variable?
A variable is a named memory location. It is used to store program’s input data and its computational result during execution of program. The value of a variable may change during the execution of program but the name of variable cannot be changed.
Example of variable: roll_no = 10;
Remember: you cannot be able to use space between the name of variable. You can use underscore and. And you can also not be able to start variable name with numbers and special characters.
Data types
There are four types of data in “C”. Which are Integer, Float, Character (String) and Boolean. These data types are used to define a variable before using. You must have to define the data type of variable which you are going to use.
See the data types below
Integer: Integer data type is defined as “int”. By using this data type you can just store numerical date like 0,1,2,3,4,5. It means you can just store numbers. You cannot be able to store names and special character like $,&.
Example of integer: int roll_no = 50;
Float: In float data type you can store floating point data like 14.5 and 2.0 etc. You can use this data type by “float”.
Example of Float: float height = 5.6;
Character (string): Character data type is defined by word “char” in “C”. This data type is used for storing character data like name and special characters etc.
Example of character: char dollar = ‘$’;
Boolean: Boolean data type is used for writing storing true or falls conditions. It is defined by word “bool”.
Example: bool condition = true;
Comparing operators“==”:
This symbol is used for comparing two things. This is used for check whether the given condition is equal to. In “C” programming single equal to is used for assign some value to a variable and double equal to is used for comparing two variables.
Some other comparing operators are below. I thing you know about these signs which are below.
“>” “<” “>=” “=<” “!=”
If statement
”If” statement is used for checking some condition. “If” statement is a very good functionality of “C” language. The syntax of “If” statement is below.
If(condition){
This part will execute when the condition is true.
}
“else” statement
“else” statement will be executed if the condition is falls. It means that we use this statement when the given condition will not satisfy. See example.
int student_age = 20;
Example: if(student_age < 18 ){
printf(“welcome”);
}else{
Printf(“Sorry you are over age!”);
}
Output: Sorry you are over age!
Detail: In the above program I give the condition that if the student age is less than 18 then print “Welcome” or if the student age is greater than 18 then print “Sorry you are over age”. So this is the use of “if” and “else” statements.
0 comments:
Post a Comment