Skip to main content

Posts

Pascals Triangle Program In C. By [CodeWithYash]

/*P6.25 Pascal’s triangle*/ #include<stdio.h> long factorial(int); long comb(int,int); int main(void) { int i,j,k; printf("Enter number of rows  for Pascal's triangle : "); scanf("%d",&k); for(i=0; i<k; i++) { for(j=0; j<=i; j++) printf("%5ld",comb(i,j)); printf("\n"); } return 0; } long comb(int n,int r) { long c; c=factorial(n)/(factorial(r)*factorial(n-r)); return c; } long int factorial(int n) { int i; long int fact=1; if(n==0) return 1; for(i=n; i>1; i--) fact*=i; return fact; }
Recent posts

Snake Water Or Gun Game

  import  random # Snake Water Gun or Rock Paper Scissors def   gameWin ( comp ,  you ):      # If two values are equal, declare a tie!      if  comp  ==  you:          return   None      # Check for all possibilities when computer chose s      elif  comp  ==   's' :          if  you == 'w' :              return   False          elif  you == 'g' :              return   True           # Check for all possibilities when computer chose w      elif  comp  ==   'w' :          if  you == 'g' :              return   False          elif  you == 's' :              return   True           # Check for all possibilities when computer chose g      elif  comp  ==   'g' :          if  you == 's' :              return   False          elif  you == 'w' :              return   True print ( "Comp Turn: Snake(s) Water(w) or Gun(g)?" ) randNo  =  random.randint( 1 ,  3 )  if  randNo  ==   1 :     comp  =   's' elif  r

Comments in python

 Comments Comment is used with 2 types First It can be used when you want to tell that if anyone read they can understand what is it? Second It can be used that you don't want to remove the code but also not to delete.  How to use comments? Just Do Shift+Forwardslash/ on the line It is done!

Pip in python

 Pip: A pip download a module from the internet. But the question is How to install it🤔? It's very simple. Simply, Just type pip install Module Name. You can type it in your windows PowerShell. Example: See, I want to download flask So, i can just type pip install flask Note: Don't Know about Module? Read  It Here! https://codewithyk.blogspot.com/2020/10/modules-in-python.html