Lab Task C Programs
Lab Task C Programs
REG NO Fa22-bse-064
1. Prompt the user to input 5 values and display the minimum number amongst them.
program:
#include<stdio.h>
int main()
scanf("%d", &n1);
scanf("%d", &n2);
scanf("%d", &n3);
scanf("%d", &n4);
scanf("%d", &n5);
}
else if(n2< n1 && n2< n3 && n2<n4 && n2<n5){
return 0;
2. Input 5 values from the user and display the number of positives, the number of negatives and the
number of zeros amongst the 5 values
program:
#include<stdio.h>
int main()
scanf("%d", &n1);
scanf("%d", &n3);
scanf("%d", &n4);
scanf("%d", &n5);
int positiveCount = (n1 > 0) + (n2 > 0) + (n3 > 0) + (n4 > 0) + (n5 > 0);
int negativeCount = (n1 < 0) + (n2 < 0) + (n3 < 0) + (n4 < 0) + (n5 < 0);
return 0;
3. Prompt the user to input a character and display whether it is a vowel or consonant using switch
statement.
program:
#include<stdio.h>
int main()
char ch;
printf("enter a character\n");
scanf("%c", &ch);
switch(ch){
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
break;
default :
return 0;
Home Task
1. Ask the user to enter marks obtained in a course and the total marks of the course. Then display a
menu Press 1 to calculate percentage. Press 2 to display grade. If the user presses 1 then percentage
should be displayed and if the user presses 2 the grade against the marks should be displayed. (Hint: use
switch statement for menu selection and else if to display the grade)
program:
#include<stdio.h>
int main()
{
int a;
float obtmark;
float totmark;
float per;
scanf("%f", &obtmark);
printf("%f\n", obtmark);
scanf("%f", &totmark);
printf("%f\n", totmark);
scanf("%d", &a);
switch(a){
case 1:
per = obtmark/totmark*100.0;
printf("percentage is %.2f",per);
break;
case 2:
per = obtmark/totmark*100.0;
if(per>= 80){
printf("grade is A\n");
printf("grade is C\n");
printf("grade is D\n");
else {
printf("F\n");
break;
default:
return 0;
2. Prompt the user to enter 3 values. For any equal values, the program should display the numbers
that are equal. (For example user input 34,6,34 the program should display the message that the 1st and
3rd values are equal)
program:
#include <stdio.h>
int main() {
scanf("%d", &value1);
scanf("%d", &value2);
scanf("%d", &value3);
} else {
return 0;