Category Archives: Codes

Prime Show

problem:
Write a program to show prime from 0 to N  where N will be taken from user.
code:

Another Logic:

Another Logic collected from this link:
http://www.techcrashcourse.com/2015/11/c-program-to-print-all-prime-numbers-between-1-to-N.html
Understood the implementation of the code.

 

Fibonacci in C(easy code logic)

code:

output:
0 1 1 2 3 5 8 13

http://www.codewithc.com/c-program-for-fibonacci-series/

Continue and Break

code 1:

output:
11
13
15
code 2:

output:
11
13
15
17

Condition and Loop problems

write a program which will take N integer from user and print all the numbers between N to -32 stop your program when user will give N=-1
code:

 

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:

 

Prime or Not

Code:

 

Sum of series

code:
series: 1/1+1/2+1/3+….+1/N

series: 1/1-1/2+1/3-1/4+1/5….1/N
code:

Series: 1^2/1!+2^2/2!+3^2/3!+4^2/4!+…..+N^2/N!

code:

Series: 1^2/1!+3^2/2!+5^2/5!+….N^2/N!

code:

program to find summation of squares of all numbers  from 5 to 25
series: 25+36+49+…..+625=?

code:

 

 

Palindrome or Not

Code:

 

Find sum of digits of a given number in C

Code:

With While Loop

With for loop:
Check below I didn’t initialized the for loop,

For Loop Another:

 

with do while loop

 

C refresh for logic development

Code:

Output:

How to extract a single digit from a number

Divide a number by 10 will give you a digit as int sample:
256/10=25.6==25
25/10=2.5==2

256%10=6
25%10=5
2%10=2

This video will surely help:

Code:

 

Bitwise Shifting in C

 

Stack

Vid:

Code:
Array Implementation:

OOP Implementation with Array:

 

Practice Problem:
http://www.mycodeschool.com/problems/stock-market

QuickSort

Youtube Video:

Analaysis though it seems little bit tough to me:

HackerRank video:

MIT video:
https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-introduction-to-algorithms-sma-5503-fall-2005/video-lectures/lecture-4-quicksort-randomized-algorithms/

Pseudo Code from upper Youtube vid:

 

Implementation:

Slightly edited in *A to A[]:

Some change with before and after show:

Complete Quicksort Implementation and taking user input:

Output from the above code:

Geeks for geeks:
http://quiz.geeksforgeeks.org/quick-sort/
http://www.practice.geeksforgeeks.org/problem-page.php?pid=700151

From geeks for geeks but may be there might be some problems there

ideone example: http://ideone.com/oWbONR
Others Code:
http://www.cc.gatech.edu/classes/cs3158_98_fall/quicksort.html
Recursive:
http://www.algolist.net/Algorithms/Sorting/Quicksort
CLRS:
http://www.bowdoin.edu/~ltoma/teaching/cs231/fall09/Lectures/5-quicksort/quicksort.pdf

Google Search Terms:
https://www.google.com/webhp?sourceid=chrome-instant&rlz=1C1PRFC_enBD706BD706&ion=1&espv=2&ie=UTF-8#q=quick+sort+pseudocode&*

C Refresh