pages

Monday, March 30, 2020

C Progrmming Slip 9


BCA PRACTICAL SLIPS SOLUTION

Slip 9
Q1. Write a C program to accept a character from the user and check whether the character is a
vowel or consonant. [15 Marks]
#include <stdio.h>
int main()
{
 char c;
 int isLowercaseVowel, isUppercaseVowel;
 printf("Enter an alphabet: ");
 scanf("%c",&c);
 isLowercaseVowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
 isUppercaseVowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');
 if (isLowercaseVowel || isUppercaseVowel)
 printf("%c is a vowel.", c);
 else
 printf("%c is a consonant.", c);
 return 0;
}

------------------------------------------------------------------------

Q2. Write a program to accept two numbers as range and display multiplication table
of all numbers within that range. [25 Marks]
#include <stdio.h>
int main()
{
 int i,j;
 for(j=1; j<=5; j++)
 {
 for(i=1; i<=10; i++)
 {
 //printf("\t ");
 printf(" \n %d * %d = %d ",j, i, j*i);
 }
 printf("\n");
 }
 return 0;
}

No comments:

Post a Comment