Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int isVowel(char ch)
- {
- char vowels[10] = "aeiouAEIOU";
- for(int i = 0; i<10; i++)
- {
- if(ch == vowels[i]) return 1;
- }
- return 0;
- }
- int main()
- {
- char ch;
- scanf("%c", &ch);
- if(isVowel(ch)) {
- printf("%c is vowel\n", ch);
- }
- else {
- printf("%c is consonant\n", ch);
- }
- return 0;
- }
- /*
- vowels
- a e i o u A E I O U
- 0 1 2 3 .... 9
- vowels[0]-> 'a'
- vowels[1]-> 'e'
- ..
- vowels[9]-> 'U'
- */
- #include <stdio.h>
- int main()
- {
- int n = 4;
- for(int i = 1; i<=n; i++)
- {
- int sp = n - i;
- int st = 2 * i - 1;
- for(int j = 1; j <= sp; j++) printf(" ");
- for(int j = 1; j <= st; j++) printf("*");
- printf("\n");
- }
- for(int i = 1; i<n; i++)
- {
- int sp = i;
- int k = n - i;
- int st = 2 * k - 1;
- for(int j = 1; j <= sp; j++) printf(" ");
- for(int j = 1; j <= st; j++) printf("*");
- printf("\n");
- }
- return 0;
- }
- /*
- 1
- 22
- 333
- 4444
- 55555
- 2 * i - 1
- N = 4
- * [sp = 3, st = 1]
- *** [sp = 2, st = 3]
- ***** [sp = 1, st = 5]
- ******* [sp = 0, st = 7]
- ***** [sp = 1, st = 5] i = 1
- *** [sp = 2, st = 3]
- * [sp = 3, st = 1]
- n = 4
- 5 i = 3
- 3 i = 2
- 1 i = 1
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement