c program to remove characters in string except alphabets if you enter any string then it removes all character from string except alphabet. #include<stdio.h> int main() { char line[150]; int i, j; printf("Enter a string: "); gets(line); for(i = 0; line[i] != '\0'; ++i) { while (!( (line[i] >= 'a' && line[i] <= 'z') || (line[i] >= 'A' && line[i] <= 'Z') || line[i] == '\0') ) { for(j = i; line[j] != '\0'; ++j) { line[j] = line[j+1]; } line[j] = '\0'; } } printf("Output String: "); ...
c program to insert any element in array if you want to insert any element in array at any position then go through the given programming solution below. #include<stdio.h> #include<string.h> int main(){ int a[20],i,n,p,v; printf("enter size of array\n"); scanf("%d",&n); printf("enter the element of array\n"); for(i=0;i<n;i++){ scanf("%d",&a[i]); } printf("enter the position at which you want to enter the element and value of element\n"); scanf("%d%d",&p,&v); p=p-1; printf("your final array is\n"); for(i=0;i<n;i++){ if(i==p){ a[p]=v; } printf("%d\n",a[i]); } }
c program to check an alphabet is vowel or consonant Enter any alphabet then it will give an alphabet is vowel or consonant.vowel are a,e,i,o,u.and rest all the alphabets are consonant. #include <stdio.h> int main() { char c; int isLowercaseVowel, isUppercaseVowel; printf("Enter an alphabet: "); scanf("%c",&c); // evaluates to 1 (true) if c is a lowercase vowel isLowercaseVowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'); // evaluates to 1 (true) if c is an uppercase vowel isUppercaseVowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U'); // evaluates to 1 (true) if either isLowercaseVowel or isUppercaseVowel is true if (isLowercaseVowel || isUppercaseVowel) printf("%c is a vowel.", c); else ...
Comments
Post a Comment