Skip to main content

Posts

Fibonacci Series, Prime Fibonacci Numbers

#include<stdio.h> #include<conio.h> void fibonacci ( int ); void primefibo ( int ); void main() { int n; printf("\n No. of Terms?:: "); scanf("%d",&n); fibonacci(n); printf("\n"); primefibo(n); } // Function for displaying Fibonacci Series void fibonacci(int n) { int i=2,t0=0,t1=1,tn=1; printf("\n SERIES :: "); printf("%d ",t0); while(i<n) { printf("%d ",tn); tn=t0+t1; t0=t1; t1=tn; i++; } printf("%d",tn); } // Function for displaying Prime Numbers from Fibonacci Series void primefibo ( int n ) { int i=2,t0=0,t1=1,tn=1; printf("\n Prime No. in SERIES :: "); while(i<n) { if(isprime(tn)) printf("%d ",tn); tn=t0+t1; t0=t1; t1=tn; i++; } if(isprime(tn)) printf("%d",tn); } // Function to check a number whether it is Prime or not int isprime( int n) { int i; if(i<=1) return 0; for(i=2;i<...

VIDEO CASINO (Slot Machine)

Many People spend their time and money to play CASINO Game in Hi-fi Hotel... They do in real. But if you want to spoil your money virtualy and time realy then u can use following game... So, not spoiling our time let's talk about the game design... This Game simply constructed in C Language but in console(DOS) mode also. Procedure used:: Set Player's Initial cash Take a Number between 0 to 100 from Player as input Check for valid input if input is valid goto step 5 else goto step 2 Generate a random number between 0 and 100 Compare with Player's input and computer generated Random Number if both match then goto step 8 else goto step 9 Update Win Counter and add the Player input with Player cash . goto step 10 Update Lose Counter and deduce the Player input from Player cash . Check Player's cash goes under 0 or not. if cash is less than or equal to 0 goto step 12 else goto step 2 for play again. End Program:: // Header ...

Day of Week according to Date

We have 7 days in a week. And the first Day of the Date System is Sunday . And it should be. So, 01.01.0001, i.e., First Date of Christ was Sunday. We just number the days as follows. 0 = Sunday 1 = Monday 2 = Tuesday 3 = Wednessday 4 = Thursday 5 = Friday 6 = Saturday So, we can handle every day by the reminder of 7. Cause, u just see, after every 7 days the same day is repeated. Then, lets a rough Calculation. 01/01/0001 => Sunday = 0 Now, we just try to find out the day on 1st January on next year, i.e., 01/01/0002 0001 has 365 days. So, after 365 days which day will come? To find out the answer of this question we have to perform following calculation. 7 ) 365 ( 52 35 ----- 15 14 ---- 1 The reminder is 1, i.e.,Monday. But, using this method, it is very critical to find out the day of 1st January of 1988. So, we have an another idea. Find out how many Leap years are present before current year. Suppose it is L . So, L = y/4 If Current year is...

Positive Integer as Sum of Consecutive Natural Numbers

Any Positive Integer can be represented in the form of Summation of few consecutive Natural Numbers. e.g., Say number is 27 . then it can be represented as 13 + 14 8 + 9 + 10 2 + 3 + 4 + 5 + 6 + 7 So, the following program will take the positive number and show all combination that can make the number as a Summation. import java.lang.*; import java.io.*; public class NumSum { public static void main(String[] args) throws IOException{ BufferedReader in = new BufferedReader ( new InputStreamReader(System.in)); System.out.print("\n Enter a Positive Number:: "); int n=Integer.parseInt(in.readLine()); String seq = new String(); if(n>0) { for(int i=(n/2)+1; i>=1; i--) { boolean f=true; int s=n; int j=i; for(; j>1 || s>=0; j--) { s-=j; if(s==0) { f=false; break; } } if(!f) { System.out.println(); for( ; j<i; j++) { System.out.print(j + ...