C is very basic programming language. Before starting learning this try following programs in your c compilers. 1) Print “Hello” [c]#include<stdio.h>
2) Addition of two numbers
printf("Enter 1st no.");
printf("Enter 2nd no.");
printf("The answer is : %d", c);
How to run the program
To compile press Alt+F9 To run press cntrl+F9 (if there are no errors)Lets see some of the Basic terminologies used in above 2 programs
What is printf and scanf ?
Printf function will print the text inside ” ” (double quotes). scanf will read the entered input by the user
What are data types ?
In above example i.e. addition of two numbers we have taken 3 variables a,b & c. all are of int type. int tells us that these are intergers. if we try to enter decimal values in the input it will give us error. so for that we have another datatype i.e. float using this we can use decimal values.e.g. float a,b;few more data types
What are format specifier ?
in the second program you have seen %d in scanf & printf statement. It is nothing but format specifier. It is used for integer. there are many format specifiers for e.g.
|Data type||Format specifiers|
What is an expression ?
In the above program c=a+b it is called as expression. we can use such expressions in c
why ; (semicolon) ?
In C every statement ends with semicolon . it seperates one statement from another statement.
1. Write a program for sub straction of two numbers.
2. Write a program to find area of a rectangle.
3. Write a program to find area of circle.
4. write a program to calculate the speed when user enters time & distance using the formula speed=distance/time.