Here we will see some interesting facts about C programming. These are like below.
- Sometimes the case labels of some switch statement can be placed inside if-else statement.
Example
#include <stdio.h>
main() {
int x = 2, y = 2;
switch(x) {
case 1:
;
if (y==5) {
case 2:
printf("Hello World");
}
else case 3: {
//case 3 block
}
}
}
Output
Hello World
Example
#include <stdio.h>
main() {
int array[10] = {11, 22, 33, 44, 55, 66, 77, 88, 99, 110};
printf("array[5]: %d\n", array[5]);
printf("5[array]: %d\n", 5[array]);
}
Output
array[5]: 66
5[array]: 66
- We can use <: , :> in the place of square brackets [,] and <%, %> in the place of curly braces {,}.
Example
#include <stdio.h>
main() <%
int array<:10:> = <%11, 22, 33, 44, 55, 66, 77, 88, 99, 110%>;
printf("array[5]: %d\n", array<:5:>);
%>
Output
array[5]: 66
Example
#include <stdio.h>
main() {
printf
#include "abc.txt" ;
}
Output
The Quick Brown Fox Jumps Over The Lazy Dog
- We can ignore the input using %*d in scanf().
Example
#include <stdio.h>
main() {
int x;
printf("Enter two numbers: ");
scanf("%*d%d", &x);
printf("The first one is not taken, the x is: %d", x);
}
Output
Enter two numbers: 56 69
The first one is not taken, the x is: 69