1. Write a program to find whether the given
charecter is vowel or not using SWITCH CASE
condition
2. Write a program to find whether the given number
is a positive number or not using IF ELSE
CONDITION
3. Write a Program to show whether the student has
achieved FIRST CLASS or SECOND CLASS or THIRD
CLASS or FAIL using IF ELSE CONDITION
4. Write a Program to print the first 10 decimal
numbers using FOR Loop
Answers
Answer:
1. Ans:-#include <stdio.h>
int main()
{
char ch;
/* Input an alphabet from user */
printf("Enter any alphabet: ");
scanf("%c", &ch);
/* Switch value of ch */
switch(ch)
{
case 'a':
printf("Vowel");
break;
case 'e':
printf("Vowel");
break;
case 'i':
printf("Vowel");
break;
case 'o':
printf("Vowel");
break;
case 'u':
printf("Vowel");
break;
case 'A':
printf("Vowel");
break;
case 'E':
printf("Vowel");
break;
case 'I':
printf("Vowel");
break;
case 'O':
printf("Vowel");
break;
case 'U':
printf("Vowel");
break;
default:
printf("Consonant");
}
return 0;
}
2. Ans:- #include <stdio.h>
void main()
{
int num;
printf("Input a number :");
scanf("%d", &num);
if (num >= 0)
printf("%d is a positive number \n", num);
else
printf("%d is a negative number \n", num);
}
3. Ans:- #include <stdio.h>
int main(void){
int num;
printf("Enter your mark ");
scanf("%d",&num);
printf(" You entered %d", num); // printing outputs
if(num >= 80){
printf(" You got First Class"); // printing outputs
}
else if ( num >=60){ // Note the space between else & if
printf(" You got Second Class");
}
else if ( num >=40){
printf(" You got Third Class");
}
else if ( num < 40){
printf(" You Failed in this exam");
}
return 0;
}
4. Ans:- #include <stdio.h>
void main()
{
int j, sum = 0;
printf("The first 10 natural number is :\n");
for (j = 1; j <= 10; j++)
{
sum = sum + j;
printf("%d ",j);
}
printf("\nThe Sum is : %d\n", sum);
}