This is really a easy code for swapping values of variables.Try to understand the logic. We have to take another extra integer (temp). Logic : Stored the value of “b” in “temp”. Then stored the …
This is just a simple program for Prime Number. Logic is simple. Checking the inputed number if it is divided by 2 or not. We just need to use a for loop. If you any …
If you have seen previous patterns then it is very easy. These patterns helped me understanding loops. Here is my Code : int p, q, r, k = 5; // “k” is for taking inputs …
You have to print “spaces” like the pattern 2 and print the “stars” like pattern 1. For printing “spaces” you have to use another loop before printing the “stars” and after the first loop. My …
Just made some little changes in the first code. It was easy. If you have complete idea of for loop then you can do it yourself. Feel free to share your code. Here is the …
I was just trying to solve this problem in my own way. If you have any better code then please feel free to share it in the comment section. Here is the Code : int …