SlideShare una empresa de Scribd logo
1 de 31
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Destacado

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
 

Destacado (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
 

Similar a C Prog - Strings

Similar a 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)
 

Más 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
 

Más 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
 

Último

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Último (20)

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.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