Skip to main content

Posts

Sample C Program To Delete All Vowels From A Sentence / String.

void main()   {      char sent[ ] = "She sells seashells on the seashore";      int i;      for(i = 0; sent[i] != 0; i++)        {             if(sent[i] == 97 || sent[i] == 101 || sent[i] == 105 || sent[i] == 111 || sent[i] == 117)                {                    for(;sent[i + 1] != 0; i++)                        sent[i]=sent[i + 1];                                      sent[i] = '\0';                    i =- 1;                }        }      printf("\n %s", sent);   } ALSO CHECK THESE C PROG...

Sample C Program To Count The Number Of Occurrences Of Any Two Vowels In Succession In A Line Of Text.

This program lets the user know the number of occurences of any two vowels in succession in the text passed in the program. For example, in the sentence “Please read the document carefully and then sign the gratuity form.” Such occurrences are ea, ea, ui. void main()   {      char sent[ ] = "Please read the document carefully and then sign the gratuity form.";      int i, c;      for(i = 0, c = 0; sent[ i ] != '\0'; i++)         {             if( (sent[i] == 97 || sent[i] == 101 || sent[i] == 105 || sent[i] == 117 )&&(sent[i + 1] == 97 || sent[i + 1] == 101 || sent[i + 1] == 105 || sent[i + 1] == 111 || sent[i + 1] == 117))             c++;         }      printf("\nThere are %d occurences of two vowels in succession",c);   } ALSO CHECK THESE C PROGRAMS: - C Program to count the number of wo...

Sample C Program To Compare Two Dates Using Structures.

In this program user enters two dates for comparison. In order to store date we will use structure say date that contains three members namely date, month and year. If the dates are equal then display message as “Dates are Same." otherwise “Both the dates are different”.  void main() {     int i, f = 0;     struct date       {          int date;          int month;          int year;       };     struct date d[2];     for(i = 0; i < 2; i++)       {          printf("\n Enter day for the %d date \n", i + 1);          scanf("%d",&d[i].date);          printf("\n Enter the month for the %d) date \n", i + 1);          scanf("%d",&d[i].month);          printf("\n Enter the ye...

Sample C Program to accept a string and print the reverse of the given string.

40) Sample C Program to accept a string and print the reverse of the given string. # include <stdio.h> # include <conio.h> main( ) { int i, j; char name[80]; clrscr( ); printf("Enter a string"); gets(name); for(i = 0; i < 80 && ((name [i] = getchar()) != '\n'); i++);      if(name[i]= ='\n')          name[i]='\0'; for(j=i;j>=0;j--)       putchar(name[j]); printf("Is the reverse of given string"); getch( ); } 41) Sample C Program to accept a string and check whether the given string is palindrome or not. # include <stdio.h> # include <conio.h> main( ) { int i, lim, c, check = 1; char word[80]; clrscr( ); printf("Enter a string"); for(i = 0; i < 80 && ((word [i] = getchar()) != '\n'); i++); lim = i - 1; c = lim / 2; for(i = 0; i <= 0; i++, lim--)      if(word[i] != word[lim])        {     ...

Sample C Program to accept two string and compare the strings are equal or not.

46) Sample C Program to count the number of words, characters, alphabets, vowels, consonants and digit in a line of text. # include <stdio.h> # include <conio.h> main( ) { int noa = 0, nob = 0, noc = 0, nov =0 , now = 0, noch = 0, l, I; char ch, s[100]; clrscr( ); printf(" Enter 2 lines of text: "); gets(s); l = strlen(s); for(i = 0; i < 1; i++)    {       switch(s[i])         {            case 'a':            case 'e':            case 'i':            case 'o':            case 'u':            case 'A':            case 'E':            case 'I':            case 'O':            case 'U':     ...

Sample C Program to print upper triangle.

43) Sample C Program to print upper triangle. # include <stdio.h> # include <conio.h> main( ) { int a[4][4], i, j, c; clrscr( ); printf(" Enter the no. for which you want upper triangle: "); scanf("%d", &c); for(i = 0; i < 4; i++)    for(j = 0; j < 4; j++)        if(i < j)            a[i][j] = c;        else            a[i][j] = 0; for(i = 0; i < 4; i++)    for(j = 0; j < 4; j++)      {         printf("%d:", a[i][j]);         printf('\n');      } getch( ); } 44) Sample C Program to accept two 3 dimensional array and store addition of those into the third 3-D array . # include <stdio.h> # include <conio.h> main( ) { int a[3][3], b[3][3], c[3][3], i, j; clrscr( ); for(i = 0; i < 3; i++)    for(j = 0; j...

Sample C Program For Armstrong Numbers

7) Sample C Program to print sum of individual digits of given number. # include <stdio.h> # include <conio.h> main( ) { int a, b, c, d; clrscr( ); printf ( "Enter any two digit number :"); scanf ("%d", &a); b = a / 10; c = a % 10; d = b + c; printf ("Sum of individual digits of given numbers is %d", d); getch( ); } 8) Sample C Program Program to accept a three digit number and print the sum of individual digits. # include <stdio.h> # include <conio.h> main( ) { int a, b, c, n, sum; clrscr( ); printf ("Enter a Three Digit Number:"); scanf ("%d",&n); a = n / 100; b = ( ( n % 100 ) / 10 ); c = n % 10; sum = a + b + c; printf ("Sum of Individual Digits of Given Numbers is %d", Sum); getch( ); } 9. Sample C Program to accept a number and check the given number is Armstrong or not. # include <stdio.h> # include <conio.h> main( ) { int n,...