VerkkoNet Technical Blog | C Programming
0 FOLLOWERS
Stay tuned to find articles on C programs.
VerkkoNet Technical Blog | C Programming
3y ago
Following code will reverse the given number.
#include
int main()
{
int n, reversedNumber = 0, remainder;
printf("Enter an integer: ");
scanf("%d", &n);
while(n != 0)
{
remainder = n%10;
reversedNumber = reversedNumber*10 + remainder;
n /= 10;
}
printf("Reversed Number = %d", reversedNumber);
return 0 ..read more
VerkkoNet Technical Blog | C Programming
3y ago
Have you ever think about this? Can we have a ‘C’ program without any semicolon in it?
Is that possible? Yes. Look at the code below:
#include
void main
{
if(printf(“Hello World”)){}
}
Output:
Hello World ..read more
VerkkoNet Technical Blog | C Programming
3y ago
Here’s the solution:
#include
#define decode(i,s,r,a,e,l) s##i##r##a
#define begin decode(a,m,i,n,o,l)
void begin()
{
printf(“No Main Function !!!”);
}
Does the above program run without main function? Yes, the above program runs perfectly fine even without a main function. Now, your question is “HOW? What’s the logic behind in it? How can we have a C program working without main()?”.
Now, we’ll see how. Here we are using preprocessor directive #define with arguments to give an impression that the program runs without main. But in realty it runs with a hidden main function. The ..read more
VerkkoNet Technical Blog | C Programming
3y ago
Following code will print the pyramid of numbers. To get pyramid of stars, replace integer values by the symbol “*”
Source Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int p,q,n=10,m;
clrscr();
for(p=1;p<=n;p++)
{
for(q=0;q<n-p;q++)
{
printf(” “);
}
m = p;
for(q=1;q<=p;q++)
{
if(m>9)
m = m%10;
printf(“%d “,m++);
}
m = m-2;
for(q=1;q<p;q++)
{
printf(“%d “,m–);
if(m<0)
m = 0;
}
printf(“\n\n”);
}
getch();
}
Output:
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 ..read more