Posts

Showing posts from July, 2017

Variable

                            1.6 VARIABLE We so many times come across the term “variable” .we assume them in math’s for solving some Equation . so let see what is the meaning of variable in programming . in c programming variable are Simple names used to refer to some location in memory that hold a value with which we are working . Syntax for declaration of variable:    data type   variablename : #include <stdio.h> int main(){ int firstNumber, secondNumber, sumOfTwoNumbers;     printf("Enter two integers: "); // Two integers entered by user is stored using scanf() function     scanf("%d %d", &firstNumber, &secondNumber);  // sum of two numbers in stored in variable sumOfTwoNumbers     sumOfTwoNumbers = firstNumber + secondNumber;     // Displays sum          printf("%d + %d = %d", firstNumber, secondNumber, sumOfTwoNumbers);  return 0; } der a small situation   we have to add 2 numbers so we have to write a

Basic input, output and variables

1.5 Basic Input, Output and Variables Let’s learn about Input and Output in our programs along with variables. There are many ways by which an input may be taken into the program, keyboard, mouse or touchscreen! Here we only deal with the keyboard and use the included “ stdio.h ” file which provides us the basic input-output functions. For now, remember that functions are bunch of instructions written for the sake of using it multiple times when necessary. So, as the function “ printf() ” or any which is defined in the file “ stdio.h ” which is included in our program, we can use “ printf() ” anywhere necessary. Similarly, “ scanf() ” is a function which can take input from the keyboard and is defined in “ stdio.h ”. But where will you store the input took from “ scanf() ” ? You’ll store all kind values or the inputs from the user in the memory and a simple way to do this is by storing them in Variables . In simple terms variables are certain names given to a particular kin