Saturday, October 22, 2022

BCA and B.Sc Programs - Programming in C Lab - Bharathiar University - Practical Program 7 - C Program to Count Number of vowels in a given sentence

 

Write a C Program to Count Number of vowels in a given sentence





Source code


#include<stdio.h>

void main()

{

    char str[100];

    int i,count=0;

    printf("Enter the sentence to count vowels:");

 gets(str);

    for(i=0;str[i]!='\0';i++)

    {

        if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'||str[i]=='A'||str[i]=='E'

        ||str[i]=='I'||str[i]=='O'||str[i]=='U')

        {

            count++;

        }

       

    }

    printf("\nNumber of vowels in given sentence: %d\n",count);

}


Output


Enter the sentence to count vowels:This is a program to count vowels


Number of vowels in given sentence: 10


Tuesday, October 18, 2022

BCA and B.Sc Programs - Programming in C Lab - Bharathiar University - Practical Program 6 - C Program to check whether the given string is palindrome or not using Pointers



Write a C Program to check whether the given string is palindrome or not using Pointers



 


Source code
String palindrome using pointers in c

#include<stdio.h>

#include<string.h>

void main()

{

    char str[1000];

    char *ptr1, *ptr2;

    printf("Enter the String:");

    scanf("%s",str);

    ptr1=str;

    while(*ptr1!='\0')

    {

        ++ptr1;

    }

    --ptr1;

    for(ptr2=str;ptr1>=ptr2;)

    {

        
        if(*ptr1==*ptr2)

        {

            ptr1--;

            ptr2++;

        }

        else

            break;    

    }

    if(ptr2>ptr1)

        printf("String is Palindrome");

    else

        printf("String is not a Palindrome");

}


Output

Enter the String:madam

String is Palindrome

Enter the String:hello

String is not a Palindrome



Program 12 BCA Madras University BCA Object Oriented Programming using C++ Practical Madras University Program 12 Implement a telephone directory using files

  BCA Object Oriented Programming using C++ Practical Madras University  Program 12  Implement a telephone directory using files SOURCE CODE...