SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shortingargusacademy
 
Double linked list
Double linked listDouble linked list
Double linked listraviahuja11
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C LanguageRAJWANT KAUR
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointersSushil Mishra
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkarsandeep kumbhkar
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C ProgramsKandarp Tiwari
 
Lecture 1 string functions
Lecture 1  string functionsLecture 1  string functions
Lecture 1 string functionsAwinash Goswami
 
C basics
C basicsC basics
C basicsMSc CST
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซีkramsri
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using CBilal Mirza
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File Rahul Chugh
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซีkramsri
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020vrgokila
 
Double linked list
Double linked listDouble linked list
Double linked listSayantan Sur
 

Tendances (20)

C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shorting
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
Double linked list
Double linked listDouble linked list
Double linked list
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C Language
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointers
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Lecture 1 string functions
Lecture 1  string functionsLecture 1  string functions
Lecture 1 string functions
 
C basics
C basicsC basics
C basics
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
programs
programsprograms
programs
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
Double linked list
Double linked listDouble linked list
Double linked list
 

En vedette

Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)vinay arora
 
CG - Introduction to Computer Graphics
CG - Introduction to Computer GraphicsCG - Introduction to Computer Graphics
CG - Introduction to Computer Graphicsvinay arora
 
CG - Output Primitives
CG - Output PrimitivesCG - Output Primitives
CG - Output Primitivesvinay arora
 
CG - Input Output Devices
CG - Input Output DevicesCG - Input Output Devices
CG - Input Output Devicesvinay arora
 
Search engine and web crawler
Search engine and web crawlerSearch engine and web crawler
Search engine and web crawlervinay arora
 
CG - Display Devices
CG - Display DevicesCG - Display Devices
CG - Display Devicesvinay arora
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronizationvinay arora
 
Security & Protection
Security & ProtectionSecurity & Protection
Security & Protectionvinay arora
 
Use case diagram
Use case diagramUse case diagram
Use case diagramvinay arora
 
A&D - Object Oriented Design using UML
A&D - Object Oriented Design using UMLA&D - Object Oriented Design using UML
A&D - Object Oriented Design using UMLvinay arora
 
4 java - decision
4  java - decision4  java - decision
4 java - decisionvinay arora
 
1 java - data type
1  java - data type1  java - data type
1 java - data typevinay arora
 
CS 354 Pixel Updating
CS 354 Pixel UpdatingCS 354 Pixel Updating
CS 354 Pixel UpdatingMark Kilgard
 
Open GL T0074 56 sm1
Open GL T0074 56 sm1Open GL T0074 56 sm1
Open GL T0074 56 sm1Roziq Bahtiar
 
Intellectual properties
Intellectual propertiesIntellectual properties
Intellectual propertiesSHIVANI SONI
 
Візуальні еффекти на Unity3d
Візуальні еффекти на Unity3dВізуальні еффекти на Unity3d
Візуальні еффекти на Unity3dStfalcon Meetups
 

En vedette (20)

Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)
 
CG - Introduction to Computer Graphics
CG - Introduction to Computer GraphicsCG - Introduction to Computer Graphics
CG - Introduction to Computer Graphics
 
CG - Output Primitives
CG - Output PrimitivesCG - Output Primitives
CG - Output Primitives
 
CG - Input Output Devices
CG - Input Output DevicesCG - Input Output Devices
CG - Input Output Devices
 
Search engine and web crawler
Search engine and web crawlerSearch engine and web crawler
Search engine and web crawler
 
CG - Display Devices
CG - Display DevicesCG - Display Devices
CG - Display Devices
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 
Security & Protection
Security & ProtectionSecurity & Protection
Security & Protection
 
Use case diagram
Use case diagramUse case diagram
Use case diagram
 
A&D - Object Oriented Design using UML
A&D - Object Oriented Design using UMLA&D - Object Oriented Design using UML
A&D - Object Oriented Design using UML
 
Uta005 lecture1
Uta005 lecture1Uta005 lecture1
Uta005 lecture1
 
A&D - UML
A&D - UMLA&D - UML
A&D - UML
 
Uta005 lecture3
Uta005 lecture3Uta005 lecture3
Uta005 lecture3
 
4 java - decision
4  java - decision4  java - decision
4 java - decision
 
1 java - data type
1  java - data type1  java - data type
1 java - data type
 
C Prog - Array
C Prog - ArrayC Prog - Array
C Prog - Array
 
CS 354 Pixel Updating
CS 354 Pixel UpdatingCS 354 Pixel Updating
CS 354 Pixel Updating
 
Open GL T0074 56 sm1
Open GL T0074 56 sm1Open GL T0074 56 sm1
Open GL T0074 56 sm1
 
Intellectual properties
Intellectual propertiesIntellectual properties
Intellectual properties
 
Візуальні еффекти на Unity3d
Візуальні еффекти на Unity3dВізуальні еффекти на Unity3d
Візуальні еффекти на Unity3d
 

Similaire à C Prog - Strings

Similaire à C Prog - Strings (20)

C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointers
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manual
 
C Programming
C ProgrammingC Programming
C Programming
 
Arrays
ArraysArrays
Arrays
 
Tharun prakash.pptx
Tharun prakash.pptxTharun prakash.pptx
Tharun prakash.pptx
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
C Prog. - ASCII Values, Break, Continue
C Prog. -  ASCII Values, Break, ContinueC Prog. -  ASCII Values, Break, Continue
C Prog. - ASCII Values, Break, Continue
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
Circular queue
Circular queueCircular queue
Circular queue
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
 
Basic C Programming Lab Practice
Basic C Programming Lab PracticeBasic C Programming Lab Practice
Basic C Programming Lab Practice
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 
Pnno
PnnoPnno
Pnno
 
Unix Programs
Unix ProgramsUnix Programs
Unix Programs
 
String
StringString
String
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 

Plus de vinay arora

Use case diagram (airport)
Use case diagram (airport)Use case diagram (airport)
Use case diagram (airport)vinay arora
 
SEM - UML (1st case study)
SEM - UML (1st case study)SEM - UML (1st case study)
SEM - UML (1st case study)vinay arora
 
3 java - variable type
3  java - variable type3  java - variable type
3 java - variable typevinay arora
 
2 java - operators
2  java - operators2  java - operators
2 java - operatorsvinay arora
 
A&D - Input Design
A&D - Input DesignA&D - Input Design
A&D - Input Designvinay arora
 
A&D - Object Oriented Analysis using UML
A&D - Object Oriented Analysis using UMLA&D - Object Oriented Analysis using UML
A&D - Object Oriented Analysis using UMLvinay arora
 
A&D - Use Case Diagram
A&D - Use Case DiagramA&D - Use Case Diagram
A&D - Use Case Diagramvinay arora
 

Plus de vinay arora (10)

Use case diagram (airport)
Use case diagram (airport)Use case diagram (airport)
Use case diagram (airport)
 
SEM - UML (1st case study)
SEM - UML (1st case study)SEM - UML (1st case study)
SEM - UML (1st case study)
 
6 java - loop
6  java - loop6  java - loop
6 java - loop
 
3 java - variable type
3  java - variable type3  java - variable type
3 java - variable type
 
2 java - operators
2  java - operators2  java - operators
2 java - operators
 
Uta005 lecture2
Uta005 lecture2Uta005 lecture2
Uta005 lecture2
 
A&D - Input Design
A&D - Input DesignA&D - Input Design
A&D - Input Design
 
A&D - Object Oriented Analysis using UML
A&D - Object Oriented Analysis using UMLA&D - Object Oriented Analysis using UML
A&D - Object Oriented Analysis using UML
 
A&D - Use Case Diagram
A&D - Use Case DiagramA&D - Use Case Diagram
A&D - Use Case Diagram
 
A&D - Output
A&D - OutputA&D - Output
A&D - Output
 

Dernier

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 

Dernier (20)

Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 

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