Your SlideShare is downloading. ×
Program for pyramid
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Program for pyramid

1,751
views

Published on

Published in: Technology, Business

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,751
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
76
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Collection of program<br />Program to print double pyramid<br />void main(void){clrscr();int i,j,k,l,b,n;printf("Enter the value of N:");scanf("%d",&n);for(i=0;i{printf("");for(l=0;lprintf(" ");for(j=i+1;j<=n;j++)printf("%d",j);for(k=n-1;k>i;k--)printf("%d",k);}b=n-1;for(i=0;i{printf("");for(l=n-2;l>i;l--)printf(" ");for(j=b;j<=n;j++)printf("%d",j);for(k=n-1;k>=b;k--)printf("%d",k);b--;}getch();}<br />WAP to print fabbonic series from 1 to 55<br />void main ()<br />{<br />int a,b,c;<br />clrscr ();<br />a=0;b=1;c=1;<br />printf ("%dn%d",a,b);<br />while (c<55)<br />{<br />c=a+b;<br />printf ("n%d",c);<br />a=b;<br />b=c;<br />}<br />getch ();<br />}<br />factorial<br />#include "stdio.h"#include "conio.h"long int factorial(int n);void main(){int n,i;float s,r;char c;clrscr();repeat : printf("You have this series:- 1/1! + 2/2! + 3/3! + 4/4!");printf("To which term you want its sum? ");scanf("%d",&n);s=0;for (i=1;i<=n;i++){s=s+((float)i/(float)factorial(i));}printf("The sum of %d terms is %f",n,s);fflush(stdin);printf ("Do you want to continue?(y/n):- ");scanf("%c",&c);if (c=='y')goto repeat;getch();}long int factorial(int n){if (n<=1)return(1);elsen=n*factorial(n-1);return(n);} <br />//C Program to Print Square of Stars#include<stdio.h>#include<conio.h>void main(){int a,b;clrscr();for(a=1;a<=3;a++){for (b=1;b<=a;b++){if(a==2&&b==2){printf(" ");}else{printf("*");}}for(b=(3-a);b>=1;b--){printf("*");}printf("n");}getch();}<br />/*c program for printing Pascal's Triangle*/#include <stdio.h>#include <conio.h>void main(){int p[10][10];int i,j,k;clrscr();printf("nPascal's Trianglen");for(i=0;i<10;i++){j=1;p[i][0]=1;p[i][i]=1;while(j<i){p[i][j]=p[i-1][j-1]+p[i-1][j];j++;}}for(i=0;i<10;i++){j=10;while(j>i){printf("  ");j--;}for(k=0;k<=i;k++){printf("%4d",p[i][k]);}printf("nn");}getch();}<br />//C Program to Round Up a Number#include<stdio.h>#include<conio.h>void main(){float n;int i;clrscr();printf("nEnter the Valuenn");scanf("%f",&n);i=(n<0)?n-0.5:n+0.5;printf("nRound up value= %d",i);getch();}<br />Fuuny program<br />#include<stdio.h>#include<conio.h>void main(){char ch[]="I AM AN IDIOT.";char c='A';int i=0;while(c){c=getch();printf("%ca",ch[i]);i++;if(i==14){printf(" "); i=0;}}}<br />http://free-c-programs.blogspot.com<br />by ujjwal kaushik<br />