Posts

Use of Strlen() Function

Use of Strlen() Function #include<stdio.h> #include<string.h> void main(void) { char str[31]; int len; printf("\nEnter any String"); gets(str); len=strlen(str); printf("\nNumber of Character in%s=%d\n",str,len); }

concatenate two strings

CONCATENATE TWO STRINGS WAP to concatenate two strings void main () { char *str,*str1; clrscr (); printf("Enter your name: "); gets (str); str1="jeet"; strcat(str,str1); printf("\n %s",str); getch (); }

count number of vowels

NUMBER OF VOWELS WAP to count number of vowels void main () { char s[20],vw=0,i; clrscr(); printf ("Enter any string: "); gets (s); for (i=0;i<=strlen(s);i++) { switch (s[i]) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'A': case 'E': case 'I': case 'O': case 'U': vw++; } } printf ("There are %d vowels in it",vw); getch (); }

create double dimension array of 2x3 matrix and display its Elements

Image
MATRIX 2 X 3 WAP to create double dimension array of 2x3 matrix and display its Elements void main () { int a[2][3],i,j; clrscr (); for (i=0;i<2;i++) { for (j=0;j<3;j++) { printf ("\nEnter element: "); scanf ("%d",&a[i][j]); } } for (i=0;i<2;i++) { for (j=0;j<3;j++) { printf ("%d\t",a[i][j]); } printf ("\n"); } getch (); }

find out Bigger number using Ternary Operators

Image
BIGGER NUMBER WAP to find out Bigger number from two numbers (Ternary Operators) void main () { int a,b; clrscr (); printf ("Enter the value of A: "); scanf("%d",&a); printf ("Enter the value of B: "); scanf ("%d",&b); (a>b)? printf ("A is Big"):printf("B is Big"); getch (); }

find out Quadratic Equation (d=b2-4ac)

Image
  QUADRATIC EQUATION WAP to find out Quardratic Equation (d=b2-4ac) void main () { int a,b,c,d; clrscr (); printf ("Enter A: "); scanf ("%d",&a); printf ("Enter B: "); scanf ("%d",&b); printf ("Enter C: "); scanf ("%d",&c); d= (b*b)-(4*a*c); printf ("\nAnswer is %d",d); getch (); }

Total Bill with discount using Ternary Operators

TOTAL BILL/ DISCOUNT A WAP to find out Total Bill with discount according to conditions (Ternary Operators) void main () { int b,dis,n; clrscr (); printf ("Enter Bill: "); scanf ("%d",&b); dis=(b<500)?(b*.10):(b>=500 &&amp; b<1000)?(b*.15):(b>=1000 && b<=2000)?(b*.20):(b*.25); n=b-dis; printf ("Net Bill is %d",n); getch(); }