This page will explain you basic concepts of C programming language. Following C language basic concepts are discussed through various programs given on this page:
data
types, declaring variables, assigning values to variables, processing values of
variables, displaying content to console and reading user input.
In C language any user defined name is called identifier. This name may be variable
name, function name, goto label name, any other data type name like structure,
union, enum names or typedef name. We need to follow some rules while declaring variables (identifiers) in C program. To know more about variable declaration rules click here.
We will learn use of various fundamental concepts using following C programs.
- C program to read and display roll number and percentage from user. (Use of int and float variables).
- Simple Calculator using C program.
- Storing New Line character (\n) as a user input data.
- Use of various Data Types in C program.
- Use of #define in C program.
- Use of increment (++) operator in C program.
- Use of decrement (- -) operator in C program.
- Use of arithmetic operators in C program.
- C program to find the area of a circle.
- C program to find the area of a square.
- C program to print Mark sheet.
Sample Programs
//To read roll number and marks from user and display it on screen. //This program shows how to declare and use int variables. #include<stdio.h> void main() { int marks,rollno; printf("Enter your Roll No:"); scanf("%d", &rollno); printf("Enter your Marks:"); scanf("%d", &marks); printf("Your Roll No: %d. \n", rollno); printf("Your marks: %d", marks); } Output of the program Enter your Roll No:101 Enter your Marks:70 Your Roll No: 101. Your marks: 70 |
/*Simple Calculator using C. Addition, Subtraction, Multiplication, and Division. */ #include<stdio.h> void main() { int number1, number2; printf("Enter number1:"); scanf("%d",&number1); printf("Enter number2:"); scanf("%d",&number2); printf("Addition of two numbers: %d\n", number1 + number2 ); printf("Substraction of two numbers: %d\n", number1 - number2 ); printf("Multiplication of two numbers: %d\n", number1 * number2 ); printf("Division of two numbers: %d\n", number1 / number2 ); } Output of the program Enter number1:10 Enter number2:5 Addition of two numbers: 15 Substraction of two numbers: 5 Multiplication of two numbers: 50 Division of two numbers: 2 |
* * * * *
Its really great blog for C beginners......
ReplyDeleteGood blog
ReplyDeleteThank u. I am starting again to learn through ur web.
ReplyDeleteIt's good
ReplyDelete