BCA

C LAB :PART A

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

C LAB : PART B

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

Write a C Program to demonstrate string functions (at least 3).

 

  /*Write a C Program to demonstrate string functions (at least 3). */




#include < stdio.h>
#include < string.h>
#include< conio.h>
void main()
{
     char s1[30] = "string 1";
     char s2[30] = "string 2 : I’m gonna copied into s1";


     char s3[10] = "Hello";
     char s4[10] = "World";

 char nickname[20];

    /* Console display using puts */
    puts("Enter your Nick name:");

    /*Input using gets*/
    gets(nickname);

    puts(nickname);


//concat
     strcat(S3,S4);
     printf("Concatenation using strncat: %s", S3);

//compare
    if (strcmp(s1, s2) ==0)
     {
         printf("\nstring 1 and string 2 are equal");
     }else
     {
         printf("\nstring 1 and 2 are different");
     }

     /* this function has copied s2 into s1*/
     strcpy(s1,s2);
     printf("\nString s1 is: %s", s1);
  getch();
}