C Programming - Strings

Organized By: Vinay Arora
               Assistant Professor, CSED
               Thapar University, Patiala
Program - 1

        #include<stdio.h>
        #include<conio.h>
        void main()
         {
          char a[]="CIVIL DEPARTMENT";
          int i=0;
          clrscr();

          for(i=0;i<=15;i++)
           {
            printf("%c",a[i]);
           }
         getch();
         }


                            Vinay Arora
                               CSED
Program – 1 (output)




                Vinay Arora
                   CSED
Program - 2
        #include<stdio.h>
        #include<conio.h>
        void main()
         {
          char a[30]="CIVIL DEPARTMENT";
          int i=0;
          clrscr();

         while(a[i]!='0')
           {
            printf("%c",a[i]);
            i++;
           }
         getch();
         }


                             Vinay Arora
                                CSED
Program – 2 (output)




                Vinay Arora
                   CSED
Program - 3

        #include<stdio.h>
        #include<conio.h>
        void main()
         {
          char a[]="CIVIL DEPARTMENT";
          clrscr();

         printf("%s",a);

         getch();
         }




                           Vinay Arora
                              CSED
Program – 3 (output)




                Vinay Arora
                   CSED
Program - 4
        #include<stdio.h>
        #include<conio.h>

        void main()
         {
          char a1[]={'C','I','V','I','L'};
          char a2[]={'C','I','V','I','L','0'};
          char a3[6]={'C','I','V','I','L'};
          clrscr();

         printf("n%s",a1);
         printf("n%s",a2);
         printf("n%s",a3);

         getch();
         }

                               Vinay Arora
                                  CSED
Program – 4 (output)




                Vinay Arora
                   CSED
Program - 5
       #include<stdio.h>
       #include<conio.h>
       void main()
        {
         char a1[6]={'C','I','V','I','L'};
         clrscr();

        printf("n%s",a1);
        printf("n%.3s",a1);
        printf("n%-6.2s",a1);
        printf("n%6.2s",a1);
        printf("n%10s",a1);
        printf("n%5s",a1);

        getch();
        }

                                Vinay Arora
                                   CSED
Program – 5 (output)




                Vinay Arora
                   CSED
Program - 6
        #include<stdio.h>
        #include<conio.h>
        void main()
         {
          char text[20];
          int length;
          clrscr();

         printf("Type the Text belown");
         gets(text);
         length=strlen(text);
         printf("Length of string = %d",length);

         getch();
         }


                            Vinay Arora
                               CSED
Program – 6 (output)




                Vinay Arora
                   CSED
Program - 7
   #include<stdio.h>
   #include<conio.h>                                      getch();
   void main()
    {                                                       }
     char str1[20], str2[20];
     int length;
     clrscr();

    printf("Enter 1st stringn");
    gets(str1);
    printf("Enter 2nd stringn");
    gets(str2);

    printf("n1st String is --->t%s",str1);
    printf("n2nd String is --->t%s",str2);

    strcpy(str1,str2);

    printf("nn1st String after strcpy() is --->t%s",str1);

                                         Vinay Arora
                                            CSED
Program – 7 (output)




                Vinay Arora
                   CSED
Program - 8
  #include<stdio.h>
  #include<conio.h>                                            getch();
  void main()
   {                                                            }
    char str1[20], str2[20];
    int length;
    clrscr();

   printf("Enter 1st stringn");
   gets(str1);
   printf("Enter 2nd stringn");
   gets(str2);

   printf("n1st String is --->t%s",str1);
   printf("n2nd String is --->t%s",str2);

   strncpy(str1,str2,2);

   printf("nn1st String after strcpy() is --->t%s",str1);
                                          Vinay Arora
                                             CSED
Program – 8 (output)




                Vinay Arora
                   CSED
Program - 9
  #include<stdio.h>
  #include<conio.h>                                         getch();
  void main()
   {                                                        }
    char str1[20], str2[20];
    int result;
    clrscr();

   printf("Enter 1st stringn");
   gets(str1);
   printf("Enter 2nd stringn");
   gets(str2);

   printf("n1st String is --->t%s",str1);
   printf("n2nd String is --->t%s",str2);

   result=strcmp(str1,str2);
   //In case of match result will be ZERO otherwise NON ZERO
   printf("nnResult after Comparing is %d",result);

                                              Vinay Arora
                                                 CSED
Program – 9 (output)




                Vinay Arora
                   CSED
Program – 9 (output)




                Vinay Arora
                   CSED
Program - 10
       #include<stdio.h>
       #include<conio.h>
       void main()
        {
         char str1[20];
         int length;
         clrscr();

        printf("Enter 1st stringn");
        gets(str1);

        printf("n1st String is --->t%s",str1);

        strupr(str1);

        printf("nnString after strupr() is --->t%s",str1);

        getch();
        }
                               Vinay Arora
                                  CSED
Program – 10 (output)




                Vinay Arora
                   CSED
Program - 11
     #include<stdio.h>
     #include<conio.h>                              getch();
     void main()
      {                                              }
       char str1[20],str2[20];
       int length;
       clrscr();

      printf("Enter 1st stringn");
      gets(str1);
      printf("Enter 2nd stringn");
      gets(str2);

      printf("n1st String is --->t%s",str1);
      printf("n2nd String is --->t%s",str2);

      strcat(str1,str2);

      printf("nnString after strcat() is --->t%s",str1);
                                      Vinay Arora
                                         CSED
Program – 11 (output)




                Vinay Arora
                   CSED
Program - 12
   #include<stdio.h>
   #include<conio.h>                                  getch();
   void main()
    {                                                   }
     char str1[20],str2[20];
     int length;
     clrscr();

    printf("Enter 1st stringn");
    gets(str1);
    printf("Enter 2nd stringn");
    gets(str2);

    printf("n1st String is --->t%s",str1);
    printf("n2nd String is --->t%s",str2);

    strcat(str1," ");
    strcat(str1,str2);
    printf("nnString after strcat() is --->t%s",str1);

                                       Vinay Arora
                                          CSED
Program – 12 (output)




                Vinay Arora
                   CSED
Program - 13
       #include<stdio.h>
       #include<conio.h>
       void main()
        {
         char str1[20];
         int length;
         clrscr();

        printf("Enter 1st stringn");
        gets(str1);

        printf("n1st String is --->t%s",str1);

        strrev(str1);

        printf("nnString after strrev() is --->t%s",str1);

        getch();
       }

                                Vinay Arora
                                   CSED
Program – 13 (output)




                Vinay Arora
                   CSED
Program - 14
  #include<stdio.h>                printf("n1st String is --->t%s",str1);
  #include<conio.h>
  void main()                       strrev(str1);
   {
    char c,str1[30];                printf("nnString after strrev() is --->t%s",str1);
    int length,i=0;
    clrscr();                       getch();
                                   }
   printf("Enter 1st stringn");

   c=getchar();
   while(c!='@')
    {
      str1[i]=c;
      i++;
      c=getchar();
    }


                                      Vinay Arora
                                         CSED
Program – 14 (output)




                Vinay Arora
                   CSED
Thnx…



  Vinay Arora
     CSED

More Related Content

PDF
C Prog. - Structures
PDF
C Prog. - Strings (Updated)
PDF
C Prog - Array
PDF
C programms
DOCX
C lab manaual
DOCX
DataStructures notes
DOCX
C Prog. - Structures
C Prog. - Strings (Updated)
C Prog - Array
C programms
C lab manaual
DataStructures notes

What's hot (20)

PPSX
C programming array & shorting
DOCX
SaraPIC
PPTX
Double linked list
DOCX
Practical File of C Language
PDF
c-programming-using-pointers
PPTX
4. chapter iii
PPT
All important c programby makhan kumbhkar
DOCX
DAA Lab File C Programs
DOCX
ADA FILE
PPTX
Lecture 1 string functions
DOC
C basics
PPTX
ภาษาซี
PPTX
3. chapter ii
PDF
Data Structure using C
DOCX
Data Structures Using C Practical File
PPTX
ภาษาซี
PDF
programs
DOC
Basic c programs updated on 31.8.2020
PPTX
Double linked list
PPTX
C programming array & shorting
SaraPIC
Double linked list
Practical File of C Language
c-programming-using-pointers
4. chapter iii
All important c programby makhan kumbhkar
DAA Lab File C Programs
ADA FILE
Lecture 1 string functions
C basics
ภาษาซี
3. chapter ii
Data Structure using C
Data Structures Using C Practical File
ภาษาซี
programs
Basic c programs updated on 31.8.2020
Double linked list
Ad

Viewers also liked (20)

DOCX
Lab exercise questions (AD & CD)
PDF
CG - Introduction to Computer Graphics
PDF
CG - Output Primitives
PDF
CG - Input Output Devices
PDF
Search engine and web crawler
PDF
CG - Display Devices
PPT
Process Synchronization
PPT
Security & Protection
DOCX
Use case diagram
PDF
A&D - Object Oriented Design using UML
PPT
Uta005 lecture1
PPT
A&D - UML
PPT
Uta005 lecture3
PPT
4 java - decision
PPT
1 java - data type
PDF
C Prog - Array
PPT
CS 354 Pixel Updating
PDF
Open GL T0074 56 sm1
PPTX
Intellectual properties
PDF
Візуальні еффекти на Unity3d
Lab exercise questions (AD & CD)
CG - Introduction to Computer Graphics
CG - Output Primitives
CG - Input Output Devices
Search engine and web crawler
CG - Display Devices
Process Synchronization
Security & Protection
Use case diagram
A&D - Object Oriented Design using UML
Uta005 lecture1
A&D - UML
Uta005 lecture3
4 java - decision
1 java - data type
C Prog - Array
CS 354 Pixel Updating
Open GL T0074 56 sm1
Intellectual properties
Візуальні еффекти на Unity3d
Ad

Similar to C Prog - Strings (20)

PDF
C Prog - Pointers
DOCX
Data structure new lab manual
DOCX
C Programming
PPTX
Tharun prakash.pptx
PDF
C Programming Example
PDF
C Prog. - ASCII Values, Break, Continue
PDF
C Programming lab
DOCX
Circular queue
PPSX
Concepts of C [Module 2]
PPTX
C Programming Language Part 8
PDF
Bcsl 033 data and file structures lab s1-1
PDF
Basic C Programming Lab Practice
DOCX
Chapter 8 c solution
PDF
Data Structure in C Programming Language
PDF
C programs Set 2
PPTX
programming for problem solving using C-STRINGSc
PPTX
Lecture 24 PART 1.pptxkhfwraetrsytfyugiuihjojiiyutdruot8
PDF
Principals of Programming in CModule -5.pdfModule-4.pdf
PDF
Unix Programs
C Prog - Pointers
Data structure new lab manual
C Programming
Tharun prakash.pptx
C Programming Example
C Prog. - ASCII Values, Break, Continue
C Programming lab
Circular queue
Concepts of C [Module 2]
C Programming Language Part 8
Bcsl 033 data and file structures lab s1-1
Basic C Programming Lab Practice
Chapter 8 c solution
Data Structure in C Programming Language
C programs Set 2
programming for problem solving using C-STRINGSc
Lecture 24 PART 1.pptxkhfwraetrsytfyugiuihjojiiyutdruot8
Principals of Programming in CModule -5.pdfModule-4.pdf
Unix Programs

More from vinay arora (10)

DOCX
Use case diagram (airport)
PDF
SEM - UML (1st case study)
PPT
6 java - loop
PPT
3 java - variable type
PPT
2 java - operators
PPT
Uta005 lecture2
PPT
A&D - Input Design
PDF
A&D - Object Oriented Analysis using UML
PPT
A&D - Use Case Diagram
PDF
A&D - Output
Use case diagram (airport)
SEM - UML (1st case study)
6 java - loop
3 java - variable type
2 java - operators
Uta005 lecture2
A&D - Input Design
A&D - Object Oriented Analysis using UML
A&D - Use Case Diagram
A&D - Output

Recently uploaded (20)

PDF
gsas-cvs-and-cover-letters jhvgfcffttfghgvhg.pdf
DOCX
HELMET DETECTION AND BIOMETRIC BASED VEHICLESECURITY USING MACHINE LEARNING.docx
PDF
Global strategy and action plan on oral health 2023 - 2030.pdf
PPTX
Juvenile delinquency-Crim Research day 3x
PDF
WHAT NURSES SAY_ COMMUNICATION BEHAVIORS ASSOCIATED WITH THE COMP.pdf
PDF
Jana Ojana 2025 Prelims - School Quiz by Pragya - UEMK Quiz Club
PDF
BP303T PHARMACEUTICALMICROBIOLOGY UNIT 1
DOCX
OA 7- Administrative Office Procedure and Management.docx
PDF
GSA-Past-Papers-2010-2024-2.pdf CSS examination
PPTX
Unit1_Kumod_deeplearning.pptx DEEP LEARNING
PDF
English 2nd semesteNotesh biology biopsy results from the other day and I jus...
PDF
NGÂN HÀNG CÂU HỎI TÁCH CHỌN LỌC THEO CHUYÊN ĐỀ TỪ ĐỀ THI THỬ TN THPT 2025 TIẾ...
PDF
Unleashing the Potential of the Cultural and creative industries
PDF
BA-1ST(Education)-Education and Society.pdf
PPTX
chapter-1-221011141445-58f8b864sdfghj.pptx
PPTX
Power of Gratitude: Honouring our teachers
PDF
IS1343_2012...........................pdf
PDF
3-Elementary-Education-Prototype-Syllabi-Compendium.pdf
PPTX
Entrepreneurship Management and Finance - Module 1 - PPT
gsas-cvs-and-cover-letters jhvgfcffttfghgvhg.pdf
HELMET DETECTION AND BIOMETRIC BASED VEHICLESECURITY USING MACHINE LEARNING.docx
Global strategy and action plan on oral health 2023 - 2030.pdf
Juvenile delinquency-Crim Research day 3x
WHAT NURSES SAY_ COMMUNICATION BEHAVIORS ASSOCIATED WITH THE COMP.pdf
Jana Ojana 2025 Prelims - School Quiz by Pragya - UEMK Quiz Club
BP303T PHARMACEUTICALMICROBIOLOGY UNIT 1
OA 7- Administrative Office Procedure and Management.docx
GSA-Past-Papers-2010-2024-2.pdf CSS examination
Unit1_Kumod_deeplearning.pptx DEEP LEARNING
English 2nd semesteNotesh biology biopsy results from the other day and I jus...
NGÂN HÀNG CÂU HỎI TÁCH CHỌN LỌC THEO CHUYÊN ĐỀ TỪ ĐỀ THI THỬ TN THPT 2025 TIẾ...
Unleashing the Potential of the Cultural and creative industries
BA-1ST(Education)-Education and Society.pdf
chapter-1-221011141445-58f8b864sdfghj.pptx
Power of Gratitude: Honouring our teachers
IS1343_2012...........................pdf
3-Elementary-Education-Prototype-Syllabi-Compendium.pdf
Entrepreneurship Management and Finance - Module 1 - PPT

C Prog - Strings

  • 1. C Programming - Strings Organized By: Vinay Arora Assistant Professor, CSED Thapar University, Patiala
  • 2. Program - 1 #include<stdio.h> #include<conio.h> void main() { char a[]="CIVIL DEPARTMENT"; int i=0; clrscr(); for(i=0;i<=15;i++) { printf("%c",a[i]); } getch(); } Vinay Arora CSED
  • 3. Program – 1 (output) Vinay Arora CSED
  • 4. Program - 2 #include<stdio.h> #include<conio.h> void main() { char a[30]="CIVIL DEPARTMENT"; int i=0; clrscr(); while(a[i]!='0') { printf("%c",a[i]); i++; } getch(); } Vinay Arora CSED
  • 5. Program – 2 (output) Vinay Arora CSED
  • 6. Program - 3 #include<stdio.h> #include<conio.h> void main() { char a[]="CIVIL DEPARTMENT"; clrscr(); printf("%s",a); getch(); } Vinay Arora CSED
  • 7. Program – 3 (output) Vinay Arora CSED
  • 8. Program - 4 #include<stdio.h> #include<conio.h> void main() { char a1[]={'C','I','V','I','L'}; char a2[]={'C','I','V','I','L','0'}; char a3[6]={'C','I','V','I','L'}; clrscr(); printf("n%s",a1); printf("n%s",a2); printf("n%s",a3); getch(); } Vinay Arora CSED
  • 9. Program – 4 (output) Vinay Arora CSED
  • 10. Program - 5 #include<stdio.h> #include<conio.h> void main() { char a1[6]={'C','I','V','I','L'}; clrscr(); printf("n%s",a1); printf("n%.3s",a1); printf("n%-6.2s",a1); printf("n%6.2s",a1); printf("n%10s",a1); printf("n%5s",a1); getch(); } Vinay Arora CSED
  • 11. Program – 5 (output) Vinay Arora CSED
  • 12. Program - 6 #include<stdio.h> #include<conio.h> void main() { char text[20]; int length; clrscr(); printf("Type the Text belown"); gets(text); length=strlen(text); printf("Length of string = %d",length); getch(); } Vinay Arora CSED
  • 13. Program – 6 (output) Vinay Arora CSED
  • 14. Program - 7 #include<stdio.h> #include<conio.h> getch(); void main() { } char str1[20], str2[20]; int length; clrscr(); printf("Enter 1st stringn"); gets(str1); printf("Enter 2nd stringn"); gets(str2); printf("n1st String is --->t%s",str1); printf("n2nd String is --->t%s",str2); strcpy(str1,str2); printf("nn1st String after strcpy() is --->t%s",str1); Vinay Arora CSED
  • 15. Program – 7 (output) Vinay Arora CSED
  • 16. Program - 8 #include<stdio.h> #include<conio.h> getch(); void main() { } char str1[20], str2[20]; int length; clrscr(); printf("Enter 1st stringn"); gets(str1); printf("Enter 2nd stringn"); gets(str2); printf("n1st String is --->t%s",str1); printf("n2nd String is --->t%s",str2); strncpy(str1,str2,2); printf("nn1st String after strcpy() is --->t%s",str1); Vinay Arora CSED
  • 17. Program – 8 (output) Vinay Arora CSED
  • 18. Program - 9 #include<stdio.h> #include<conio.h> getch(); void main() { } char str1[20], str2[20]; int result; clrscr(); printf("Enter 1st stringn"); gets(str1); printf("Enter 2nd stringn"); gets(str2); printf("n1st String is --->t%s",str1); printf("n2nd String is --->t%s",str2); result=strcmp(str1,str2); //In case of match result will be ZERO otherwise NON ZERO printf("nnResult after Comparing is %d",result); Vinay Arora CSED
  • 19. Program – 9 (output) Vinay Arora CSED
  • 20. Program – 9 (output) Vinay Arora CSED
  • 21. Program - 10 #include<stdio.h> #include<conio.h> void main() { char str1[20]; int length; clrscr(); printf("Enter 1st stringn"); gets(str1); printf("n1st String is --->t%s",str1); strupr(str1); printf("nnString after strupr() is --->t%s",str1); getch(); } Vinay Arora CSED
  • 22. Program – 10 (output) Vinay Arora CSED
  • 23. Program - 11 #include<stdio.h> #include<conio.h> getch(); void main() { } char str1[20],str2[20]; int length; clrscr(); printf("Enter 1st stringn"); gets(str1); printf("Enter 2nd stringn"); gets(str2); printf("n1st String is --->t%s",str1); printf("n2nd String is --->t%s",str2); strcat(str1,str2); printf("nnString after strcat() is --->t%s",str1); Vinay Arora CSED
  • 24. Program – 11 (output) Vinay Arora CSED
  • 25. Program - 12 #include<stdio.h> #include<conio.h> getch(); void main() { } char str1[20],str2[20]; int length; clrscr(); printf("Enter 1st stringn"); gets(str1); printf("Enter 2nd stringn"); gets(str2); printf("n1st String is --->t%s",str1); printf("n2nd String is --->t%s",str2); strcat(str1," "); strcat(str1,str2); printf("nnString after strcat() is --->t%s",str1); Vinay Arora CSED
  • 26. Program – 12 (output) Vinay Arora CSED
  • 27. Program - 13 #include<stdio.h> #include<conio.h> void main() { char str1[20]; int length; clrscr(); printf("Enter 1st stringn"); gets(str1); printf("n1st String is --->t%s",str1); strrev(str1); printf("nnString after strrev() is --->t%s",str1); getch(); } Vinay Arora CSED
  • 28. Program – 13 (output) Vinay Arora CSED
  • 29. Program - 14 #include<stdio.h> printf("n1st String is --->t%s",str1); #include<conio.h> void main() strrev(str1); { char c,str1[30]; printf("nnString after strrev() is --->t%s",str1); int length,i=0; clrscr(); getch(); } printf("Enter 1st stringn"); c=getchar(); while(c!='@') { str1[i]=c; i++; c=getchar(); } Vinay Arora CSED
  • 30. Program – 14 (output) Vinay Arora CSED
  • 31. Thnx… Vinay Arora CSED