C language program

286 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

C language program

  1. 1. 1.) /* HELLO.C -- Hello, world */ #include <stdio.h> main() { printf("Hello, worldn"); } 2.) #include<stdio.h> #include<conio.h> void main() { char ch; clrscr(); Printf("press any key n"); Scanf("%c", &ch); Printf("ASCII value is %d", ch); getch(); } 3.) #include<stdio.h> #include<conio.h> void main()
  2. 2. { char ch; clrscr(); printf("press any key n"); scanf("%c",&ch); printf("ASCII value is %d",ch); getch(); } 4.) #include<stdio.h> #include<conio.h> main() { int a,b,c,max; clrscr(); printf("enter three values",3); scanf("%d %d %d",&a,&b,&c); max=(a>b)?(a>c)?(a:c):(b>c)?(b:c); printf("largest no is %dn",max); getch(); } 5.) #include<stdio.h>
  3. 3. #include<conio.h> main() { int a,b,max; clrscr(); a=8; b=5; max=(a>b?a:b); printf("%d n",a); printf("%d n",b); printf("Largest no=%d n",max); getch(); } 6.) #include<stdio.h> #include<conio.h> main() { int a,b,c,max; clrscr(); printf("enter three values",3); scanf("%d %d %d",&a,&b,&c); max=(a>b)?(a>c)?(a:c):(b>c)?(b:c);
  4. 4. printf("largest no is %dn",max); getch(); } 7.) #include<stdio.h> #include<conio.h> #include<math.h> void main() { float r,v; clrscr(); prinftf("enter radiusn"); scanf("%f",&r); v=4.0/3* 3.14159*pow(r,3); printf("volume=%fn",v); getch(); } 8.) #include<stdio.h> #include<conio.h> void main() { char ch;
  5. 5. clrscr(); printf("ASCII values are %d",ch); printf("print value a"); getch(); } 9.) #include<stdio.h> #include<conio.h> main() { int num; clrscr(); printf("enter any number"); scanf("%d",&num); if(num>=0) printf("positive"); else printf("negative"); getch(); } 10.) #include<stdio.h> #include<conio.h> main()
  6. 6. { clrscr(); printf("hyd"); clrscr(); printf("sec"); clrscr(); printf("BDN"); } 11.) #include<stdio.h> #include<conio.h> #include<math.h> void main() { float r,v; clrscr(); prinftf("enter radiusn"); scanf("%f",&r); v=4.0/3* 3.14159*pow(r,3); printf("volume=%fn",v); getch(); }
  7. 7. 12.) #include<stdio.h> #include<conio.h> void main() { int a,b,c,d,e,f; clrscr(); a=2; b=5; c=a+b; d=a-b; e=a/b; f=a*5; printf("%d n",c); printf("%d n", d); printf("%d n",e); printf("%d n",f); getch(); }

×