Category Archives: C Tricky Programs

C Program to Calculate Sum using only One Variable

As we also talked before that the less numbers of variables in the program means less memory used by the program and in return the program also run faster. So it;s always best to reduce the number of variables used in the program, as to increase the execution time of the program.

In this post we are going to make the program to calculate sum of two integers using only a single variable. We will achieve this by making a function.

Let’s have ah Look The Program ►► Continue reading C Program to Calculate Sum using only One Variable

Advertisements

C Program to Use Printf(); Function Without The Semicolon

We all know, every statement in C is terminated by semicolon (;). The same apply to printf(); function.

Suppose we are going to print Lightning Code on the screen than statement for it will be printf(“Lightning Code”); but what if we want to print it without the semicolon after printf. Think about it, how can you do it, I know, you know how can but you did’t notice it.

Let me give you a hint, when we use if(); statement to condition something, we never use the semicolon inside the parenthesis. Now I am sure you make it out.

Let’s Have Ah Look at Program ►► Continue reading C Program to Use Printf(); Function Without The Semicolon

C Program to Find The Second Largest Element Of An Array

Arrays provide the great way to store the values. And plays ah important role in C. I made many programs on arrays. And as we know array elements are always store in Contiguous Memory Location so it’s always great to combine array with pointers that makes accessing and manipulating array more handy. 

You might made the program to find the largest element of array. I come with the code to find the second largest element and also the use of macros in the program to run it more faster and avoid re-righting the same line again and again.

Lets Have ah Look at the Program ►► Continue reading C Program to Find The Second Largest Element Of An Array

Single Line C Program for Finding The Elder One Among Three

Remember the Ram, Shayam and Ajay program (from the book Let Us C). This one clears many of my confusions about the if-else ledder. But I din;t satisfied with this one because it;s a lengthy one, not because the program is hard but it takes a little more attention for the nesting of if-else. So I thought to make it short. And tried many ways to achieve what I want. And finally I end up my searching when I learnt about the Conditional Operators ( ?,: ). These operators made me act like OMG :o. These operators actually can do many of coding go simple and I shortened many of my programs with the help of these operators.

Take a Look at the Program ►► Continue reading Single Line C Program for Finding The Elder One Among Three

C Program to Convert Fahrenheit Temperature to Celsius

When I just started coding, this was the program which made me to think, I din’t satisfied with the lengthy and complicated one program which I made first, than I went step by step to make it short and more efficient. Simply I use the rule to use less variables as possible as can to make program size short and run faster. I look for the program to eliminate the more variables as can possible. And finally I came up with the short and tricky one with proper format of the output.

Look at the Program Carefully ►► Continue reading C Program to Convert Fahrenheit Temperature to Celsius

Complete C Program for Addition of Two Integers

Let’s start from the beginning, the addition of integers. I think you surely made this program already but you did’t done this in your program. If you do so, So Congrats!! you are going by the right way. Look at the program below and make out what you forgot to include in your program. And clear that bug. ►►

Continue reading Complete C Program for Addition of Two Integers