Showing posts with label Characters. Show all posts
Showing posts with label Characters. Show all posts

C Program Character Example

How to write a C Program Character in C Programming Language ?


Solution For C Program :

C Program To Print Lines Of A Paragraph Having More Than 15 Characters

How to write a C Program To Print Lines Of A Paragraph Having More Than 15 Characters in C Programming Language ?


Solution For C Program :

/*C Program To Print Lines Of A Paragraph Having More Than 15 Characters.*/

#include<stdio.h>
#include<conio.h>

void main()
{
int i=0,n=0;
char c,s[500],temp[100];
clrscr();
printf("\nEnter the paragraph, to stop writing press (CTRL+Z)\n");
/*following code will stop reading after pressing Ctrl+Z :*/
while((c=getch())!='\x1A')
    {
    if(c=='\r')
        {
        printf("\n");
        s[i++]='\n';
        }
    else
        {
        printf("%c",c);
        s[i++]=c;
        }
    }
/*choosing lines with more than 15 characters.*/
for(i=0;s[i]!='\0';i++)
    {
    temp[n]=s[i];
    n++;
    if(s[i]=='\n')
        {
        temp[n]='\0';
        if(n>15)
        printf("\n\t%s",temp);
        n=0;
        }
    }
    if(n>15)
        {
        temp[n]='\0';
        printf("\n\t%s",temp);
        }
getch();
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable



C Program To Copy One Character Array Into Another

How to write a C Program To Copy One Character Array Into Another in C Programming Language ?

Solution For C Program :

/*C Program To Copy One Character Array Into Another.*/

#include<stdio.h>
void main()
{
char str1[81], str2[81];
int k = 0;
printf("\nEnter Any Data : ");
scanf("%s", str1);
printf ("\nProcessing The String : ");
for (k = 0; str1[k] != '\0'; k++)
str2[k] = str1[k];
str2[k] = '\0' ;
printf ("\nThe Two Stings Are :\n%s \t %s", str1, str2);
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Program to Print ASCII equivalent of a character until terminated by key is ‘x’

How to write a C Program to Print ASCII equivalent of a character until terminated by key is ‘x’ in C Programming Language ?

Solution:

/* C Program to Print ASCII equivalent of a character until terminated by key is ‘x’*/

#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("Now Enter the Data. To Stop Press 'x'.\n\n");
while((ch = getch()) != 'x')
printf("The ASCII Value of %c is %d\n", ch, ch);
}

You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable

C Program to find the number of unique characters

How to write a C Program to find the number of unique characters in C programming Language ?


This C Program to find the number of unique characters.

  1.         bool dup = false;
  2.  
  3.         //find the number of unique characters
  4.         for (i=0; i < iInLen; i++){
  5.                 dup = false;
  6.                 //Go  through every character in iBuf and check if that character is in chars
  7.                 for(int k = 0; k < unchar; k++){
  8.                         if(iBuf[i] == chars[k]){
  9.                                 dup = true;
  10.                         }
  11.                 }
  12.                 if(dup == false){
  13.                         chars[unchar] = iBuf[i];
  14.                         ++unchar;
  15.  
  16.                 }
  17.         }