Category Archives: ACM Technique

Swap without a temp variable

It’s possible with addition:

It’s also possible with multiplication:

 

 

 

Source:
http://www.geeksforgeeks.org/swap-two-numbers-without-using-temporary-variable/

 

Recursion in C

code:

Another code:
it’s not tail recursion

//printing from stack

 

Recursion Example

code:

 

Void clear in C

We  see lots of void in C. Lets clear why we all use  this.

it means  it will return int type value but will not take any parameters..it is also good to define in function prototype

it means it will return int type value but will take parameters that is defined:

it means it will return nothing and if we use return here it will show error as void can’t return a value

but we can return from a condition here is one example:

 

but if we use return value with int return type it will return 1 as true returning.
example could be written as:

Source: Took some help:
http://stackoverflow.com/questions/1043034/what-does-void-mean-in-c-c-and-c
http://stackoverflow.com/questions/416345/is-fvoid-deprecated-in-modern-c-and-c

Extract Digits From a Number and Make a Sum of all the digits and show this in C

Code is here:

Output:

Modular Beautiful Code: 😀

Actually array return function is not directly possible in C and I am finding the solution here.

Took Slightly Help From this link:
https://cboard.cprogramming.com/c-programming/150996-extracting-digits-integer.html

http://mathforum.org/library/drmath/view/56002.html

Find Is It Armstrong Number or Not

code by me:

Logic and Code From the Vids:

Vid:

String Secret Revealed in C

String Input Take Without any gets function just scanf is enough for taking any input withlout gets function

another example:

another:

 

 

Modulo in Details

We can easuly get a range of output value after mod:
Code: for 100 here print from 0 to 99 range

Another Code: here for 1000 it will print 0 to 999 range

 

Learn Modulo in Easy Way

One thing was confusion for me but after watching this tut it is clear to me now.

a%n
if n>a then the result of the modulo result is a, that means a%n=a when a<n

if a<b then a%b is always a

Logic to Find First and Last Digit

Last Digit:

First Digit:

 

 

String Frequency Count

code:
simple code:

good output:

Reference: http://www.codeforwin.in/2015/04/c-program-to-calculate-the-frequency-of-each-character-in-a-line.html

101cproblems.com solution:

 

 

String Palindrome Problem

My Own Logic:

Another logic:

Simple:

another good logic:

 

 

Find maximum and minimum value in an array

for maximum:

 

for minimum:

 

Continue and Break

code 1:

output:
11
13
15

Continue Easily Explained:

Output:

Good Vid for Easy Explanation:

code 2:

output:
11
13
15
17
Easily Explained Code:

Output:

Theory for this easy explanation:

Pattern Printing

Problem:
****
***
**
*

code:

Problem:
*
**
***
****
code:

Problem:
*
Blank Line
***
Blank Line
*****
Blank Line
*******
code:

Problem:
1
12
123
1234
12345
code:

problem:
12345
1234
123
12
1

code:

Problem:

code:

Problem:

code:

Problem:

code:

problem:

code: