Вы находитесь на странице: 1из 18

kjKk

//wap to print hello world #include<stdio.h> #include<conio.h> void main() { clrscr(); printf("hello world"); getch(); }

kjKk

N //wap to print table #include<stdio.h> #include<conio.h> void main() {int i; for(i=1;i<=10;i++) printf("2*%d=%d/n",i,i*2); scanf("%d",&i); getch(); }

kjKk

fd

//wap to write colour method #include<stdio.h> #include<conio.h> void main() {clrscr(); textcolor+blink(1); cprintf("welcome to colours"); getch(); }

kjKk

//wap to write kbhit method #include<stdio.h> #include<conio.h> void main() { int color=1; while(!kbhit()) {textcolor(color); cprintf("\n hello"); delay(100); color++; } getch(); }

kjKk

//wap to show increasing series #include<stdio.h> #include<conio.h> void main() { int a,b,c; clrscr(); printf("entera,b,c:"); scanf("%d %d %d",&a,&b,&c); if(a>b&&b>c) { printf("a is greater"); } else if(b>a&&b>c) { printf("\n b is greater"); } else { printf("\n c is greater"); } getch();

kjKk

//wap to add two numb. #include<stdio.h> #include<conio.h> void main() { int a,b,sum; clrscr(); printf("enter the value of a:"); scanf("%d",&a); printf("\n enter the value of b:"); scanf("%d",&b); sum=a+b; printf("\n sum is %d",sum); getch();

kjKk

//wap to find fabonacci series #include<stdio.h> #include<conio.h> void main() { int i=0; int a=0,b=1,c; clrscr(); printf("%d %d",a,b); while(i<6) {

kjKk

c=a+b; printf("%d ",c); a=b; b=c; i++; } getch(); }

//wap to write gets method #include<stdio.h> #include<conio.h> void main() { char s[80];

kjKk

printf("type a string less than 80 characters:"); gets(s); printf("/n the string typed is:"); puts(s); getch(); }

//wap to show gotoxy method #include<stdio.h> #include<conio.h> void main() {int x,y; clrscr(); x=10; y=10;

kjKk

gotoxy(x,y); printf("to shift cursor position on c"); getch(); }

kjKk

//wap to print a patern #include<stdio.h> #include<conio.h> void main() { int i,j,k; clrscr(); for(i=1;i<=4;i++) { for(j=1;j<=4-i;j++) { printf(" "); } for(k=1;k<=(2*i)-1;k++); { printf("*"); } printf("\n"); } getch(); }

kjKk

//wap to print new pattern #include<stdio.h> #include<conio.h> void main() { int n,i,k; clrscr(); printf("value of n is:"); scanf("%d",&n); for(i=1;i<=n;i++) { for(k=1;k<=i;k++) printf("*",&k); printf("\n"); } getch(); }

kjKk

//wap to check weather no. is prime #include<stdio.h> #include<conio.h> void main() { int n,i; clrscr(); printf("The numb is:"); scanf("%d",&n); for(i=2;i<=n-1`;i++) { if(n%i==0) { printf("%d the numb is not prime /n",n); break; } }

kjKk

if(i==n) printf("%d the numb is prime /n",n); getch(); }

//wap to find largest of two numb using funct #include<stdio.h> #include<conio.h> void main()

kjKk

{int large(int a,int b),a,b; clrscr(); printf("the value of a:"); scanf("%d",&a); printf("/n the value of b:"); scanf("%d",&b); if(a>b) printf("/n a is largest"); else if(b>a) printf("/n b is largest"); else printf("are equal"); getch(); }

//wap to do swaping by call by value #include<stdio.h> #include<conio.h>

kjKk

void main() { void swap(int x,int y); int a=5,b=7; clrscr(); printf("oiginal value of :a=%d & b=%d",a,b); swap(a,b); getch(); } void swap(int x,int y) { int temp; temp=x; x=y; y=temp; printf("values after swaping are: a=%d & b=%d",x,y); }

kjKk

//wap to do swaping call by refrence #include<stdio.h> #include<conio.h> void main() { void swap(int *x,int *y) ; int a=5,b=7; clrscr(); printf("original values are:a=%d & b=%d",a,b); swap(&a,&b); getch(); } void swap(int *x,int *y) { int temp; temp=*x; *x=*y; *y=temp; printf("/n values after swaping are a=%d & b=%d",*x,*y); }

kjKk

Вам также может понравиться