String in c

1. write a c program to check whether an alphabet is vowel or consonant?

#include <stdio.h>

main()

{

    char c;

    int lowercase_vowel, uppercase_vowel;

    printf("Enter an alphabet: ");

    scanf("%c", &c);

    lowercase_vowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');

  uppercase_vowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');

   if (lowercase_vowel || uppercase_vowel)

        printf("%c is a vowel.", c);

    else

        printf("%c is a consonant.", c);

   

}

2.Write a c program to find the string length? 

#include<stdio.h>

main()

{

Char a[]=” abcdefgg”;

int  i;

for (i=0;a[i]!=’\0’;i++)

Printf(“length of the string is %d”, i);

}

3.Write a c program to print A to Z

#include <stdio.h>

main()

{

    char c;

   for(c='A';c<='Z'; c++)

    printf("alphabets are: ");

}

    


Comments

Popular Posts