Home ProgrammingC How to check the value of variable in C programming?

How to check the value of variable in C programming?

by Arslan ud Din Shafiq
how to check value of a number in c programming

Value of Variable in C: The following source code is written in C Programming language. It mainly consists of four sections. First section imports standard input-output library.

Section 2 is a void function which returns nothing but prints ‘=’ sign on the screen as per loop’s instruction. This loop starts from 1 and repeats until value becomes equal to 35. In each iteration, loop increments 1 in value of i. If I modify i++ to i+2 or i+3, it will add 2 or 3 respectively each time in previous value of i.

Section 3 is also a void function which returns nothing but prints new line with \n and my name.

Section 4 is main function where we make call to above created functions to render via function call line(); and header();.

int a initializes a variable of integer type. printf shows message to user and scanf waits for user to give some input. if is conditional statement which checks either user has entered value 7 or not.I have used != (not operator) to check, so it will be true, input value will not be 7 and vice versa. I have given source code below, you may copy it and run in your computer. If you find any issue, you may leave comment.

//section 1

//section 2
void line()
int i;
//section 3
void header()
printf(" Coded by Arslan ud Din Shafiq");
printf("\n           www.imarslan.com");
//section 4
int main()

int a;
printf("\nEnter a Number : ");
if (a!=7)
    printf("\nThe variable is not equal to 7.");
else printf("You have entered variable 7.\n");
return 0;
0 comment

You may also like

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More