Guys, if the variable is declared, then how is it possible to initialize it? from declaration to initialization? like how to change it and put the input process?
#include <stdio.h>
void main ()
{
int a = 5, b = 5, c = 10, result;
result = (a == b) && (c > b);
printf("(a == b) && (c > b) is %d \n", result);
result = (a == b) && (c < b);
printf("(a == b) && (c < b) is %d \n", result);
result = (a == b) || (c < b);
printf("(a == b) || (c < b) is %d \n", result);
result = (a != b) || (c < b);
printf("(a != b) || (c < b) is %d \n", result);
result = !(a != b);
printf("!(a == b) is %d \n", result);
result = !(a == b);
printf("!(a == b) is %d \n", result);
}
you can initialize variable after declaration as many times as you want
C++ terminology can be confusing, but let's be a bit careful at least. You can only initialize something once (perhaps being "default initialized" if you're not setting it to anything explicitly). After that, you're assigning to it.
That being said, I'm not actually sure what OP is asking, so what you said might make more sense for him :)
if i change the code, what would be the input or the scanf process? what would I put? after the printf? like for example you're putting printf("Enter Number:"); something like this.
scanf("%d",&n1);
#include <stdio.h>
void main ()
{
int a ,b, c, result;
result = (a == b) && (c > b);
printf("(a == b) && (c > b) is %d \n", result);
result = (a == b) && (c < b);
printf("(a == b) && (c < b) is %d \n", result);
result = (a == b) || (c < b);
printf("(a == b) || (c < b) is %d \n", result);
result = (a != b) || (c < b);
printf("(a != b) || (c < b) is %d \n", result);
result = !(a != b);
printf("!(a == b) is %d \n", result);
result = !(a == b);
printf("!(a == b) is %d \n", result);
}
void main is a bad habit. Strict language settings will not like it, but most compilers will take it when in relaxed/extended language mode. There isn't anything to gain from it, and its 1 more letter, so just type int instead and forget this exists.