Second program

#include<stdio.h>

int main()
{
int a;
return 0;
}

so in above program we used return type of int so we have to return 0 to end the execution of program.

Declaration : 

the statement at line 4 : int a;

in this statement, we are declaring or allocating the space for the integer value. this statement will create empty space for storing values of integer types.we are given a name to that space that is “a”.generally int is 4 bytes but don’t worry That doest important to know.so just remember int a; is allocating free space to a of type integer.

so imagine an empty block named a. it’s called variables.variables can be any names but it does not contain spaces in name.you can use your name as variable too.

so if you want to fill that box with any number you can give like a=5;

then the empty box will have value 5 and its no more empty.we can override it like first we gave a=5; then we give a=6; then the box will have value 6. similarly, if we give the first a=6; and then a=5; then the box will have value 5;

HOW TO TAKE VALUE OF A OR INPUT FROM USER:

so in a program we saw int a; -declaration of variable

a=5; – initialization or assigning value to the variable.but what if we want to take value from the user and assign it to variable a??? just like in calculator user click on the number then it will calculate those numbers.

so for taking inputs from user we will use

scanf(“%d”,&a);

the scanf will use to take input from users.

%d is for type of input… like for

int / integer — %d

char/character — %c

char[]/character array — %s

float / numbers with points — %f

#include<stdio.h>

int main()
{
int a;
scanf("%d",&a);
return 0;
}

Dont worry about others just remember for int /integer we use %d to scanf and print both…

then &a will assign the value which given in %d to the a…here & is operator that points the address of variable.so here we have a empty block a which has some address (address is nothing but information of location similar as your home address so we can reach someone by his address similarly all blocks have an address) .

so %d will take integer value from user and assign this value to the address of a…. just like courier services %d will take value from user and parcel it to the block a(any variable).but it will deliver or assign values respectively like:

#include<stdio.h>

int main()
{
int aviraj_patel;
scanf("%d",&aviraj_patel);
return 0;
}

scanf(“%d %d”,&a,&b); then first %d value will assign to &a and second %d value will assign to &b.

scanf(“%d”,&variable_name);

taking value of a from user. we can give any name to a variable like

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock