Lesson 3
( Printing of integer data )
Welcome back on learn 4 free programming!
In this lesson i will show you how to print on screen the integer data.
With this simple program i will show you how to declare an integer variable and print values of those variables.
I'm going to make a new blog for all functions that we are going to use at every lesson on this blog, and i will put the link in the next lesson, so don't forget to check it out because it's going to help you to understand.
So let's start making our program. As in the previous lessons we are going to save our program (example: int_data.c).
I hope you remember what is the first step in making C program :).
example of full code :
With this simple program i will show you how to declare an integer variable and print values of those variables.
I'm going to make a new blog for all functions that we are going to use at every lesson on this blog, and i will put the link in the next lesson, so don't forget to check it out because it's going to help you to understand.
So let's start making our program. As in the previous lessons we are going to save our program (example: int_data.c).
I hope you remember what is the first step in making C program :).
- Now, first thing we are going to do is to include our header files. As in previous programs we made, we are going to use the "stdio.h".
- Open the starting "block" of program ( int main() { and close it } ).
- Next thing we need to do is do define our variables ( for this lesson i will use num1 and num2 ). Because we are going to print integer numbers we are going to type
( int num1, bum2 ; ). - Now let's assign values to the variables num1 and num2 ( i'm going to use numbers 3 and 8 ). You are probably asking how do i do this?
Well it's easy all you need to type is
num1=3 ; and num2=8 ; - Last thing we need to do is to print those values on screen. Type:
printf (" Number 1 is : %d \n Number 2 is : %d" , num1, num2) ;
#include <stdio.h>
int main()
{
int num1 , num2 ;
clrscr(); //----------------------------> This function is used to clear the screen when program starts
num1=3 ;
num2=8 ;
printf(" Number 1 is : %d \n Number 2 is : %d" , num1, num2) ;
getch(); //-------------> This function is used to wait for user to react to proceed further ( to press any key)
}
\n - is used for new line.
Okay that's it for this lesson come back to learn more about C.
I will be posting more lessons about C programming, so follow me, comment if there is something you would change and i will see you next time :) .
I will be posting more lessons about C programming, so follow me, comment if there is something you would change and i will see you next time :) .
If something doesn't work or you need help just email me on: sashans89@gmail.com and i will help you


No comments:
Post a Comment