C Lab Bca
C Lab Bca
#include<stdio.h>
#include<conio.h>
int main()
int age;
printf("your age?");
scanf("%d",&age);
if (age>=16)
printf("eligible to vote");
else
#include<stdio.h>
#include<conio.h>
int main()
int n;
if (n%2==0)
printf("even");
else
printf("odd");
3. Write a program that accepts three values from user and results out the greatest and smallest
number.
#include<stdio.h>
#include<conio.h>
int main()
printf("3. Write a program that accepts three values from user and results out the greatest and
smallest number.\n");
int a,b,c;
printf("enter 3 no?");
scanf("%d%d%d",&a,&b,&c);
if (a>b&&a>c)
{
printf("%d is the greatest number\n",b);
else
if (a<b&&a<c)
else
4. Write a program to check whether the given number is divisible by 5 and 9 or not.
#include<stdio.h>
#include<conio.h>
int main()
printf("4. Write a program to check whether the given number is divisible by 5 and 9 or not.\n");
int n;
scanf("%d",&n);
else
#include<stdio.h>
#include<conio.h>
int main()
int num;
scanf("%d",&num);
if(num%7==0)
else if(num%13==0)
else if(num%2==0)
{
printf("the given number is divisible by 2");
else
return 0;
#include<stdio.h>
#include<conio.h>
int main()
scanf("%f%f",&cp,&sp);
if (sp>cp)
profitper=((sp-cp)/cp)*100.0;
printf("profit percent=%f",profitper);
else
lossper=((cp-sp)/cp)*100.0;
printf("loss percent=%f",lossper);
}
7. Write a C program to input any character and check whether it is vowel or consonant.
#include<stdio.h>
#include<conio.h>
int main()
printf("7. Write a C program to input any character and check whether it is vowel or
consonant. \n");
char ch;
scanf("%c",&ch);
if(ch=='a')
else if (ch=='e')
else if(ch=='i')
else if(ch=='o')
else if(ch=='u')
{
printf("%c is a vowel",ch);
else
printf(" %c is a consonant",ch);
return 0;
8. Write a program to print the day of the week's name using switch case.
#include<stdio.h>
#include<conio.h>
int main()
printf("8. Write a program to print the day of the week's name using switch case.\n");
int day;
switch (day)
case 1:
scanf("%d", &day);
printf("Sunday\n");
break;
case 2:
printf("Monday\n");
break;
case 3:
printf("Tuesday\n");
break;
case 4:
printf("Wednesday\n");
break;
case 5:
printf("Thursday\n");
break;
case 6:
printf("Friday\n");
break;
case 7:
printf("Saturday\n");
break;
default:
break;
return 0;
#include<stdio.h>
#include<conio.h>
int main()
printf("9. Write a C program to check Even or Odd number using switch case\n");
int num;
scanf("%d",&num);
switch(num % 2)
case 0:
break;
case 1:
break;
default:
printf("invalid input");
break;
return 0;
10. Any year is input through the keyboard. Write a program to determine whether the year is a leap
year or not.
#include<stdio.h>
#include<conio.h>
int main()
printf("10. Write a program to determine whether the year is a leap year or not.\n");
int year;
printf(" enter the year:");
scanf("%d",&year);
else
return 0;
11. Given three points (x1, y1), (x2, y2) and (x3, y3), write a program to check if all the three points fall
#include<stdio.h>
#include<conio.h>
int main()
printf("11. write a program to check if all the three points fall on one straight line. \n");
int x1,x2,x3,y1,y2,y3;
int slope1,slope2;
scanf("%d%d%d",&x1,&x2,&x3);
scanf("%d%d%d",&y1,&y2,&y3);
return 0;
12. Given a point (x1, y1), write a program to check whether that point lies outside or inside or in circle
#include<stdio.h>
#include<conio.h>
int main()
printf("12. write a program to check whether that point lies outside or inside or in circle of
radius r and center (h, k) \n");
float h, k, r, x, y, distance;
scanf("%f", &r);
if(distance>r)
}
else if (distance<r)
else if(distance=r)
else
return 0;
13. Write a program to find out whether a triangle is quadratic, isosceles or scalene.
#include<stdio.h>
#include<conio.h>
int main()
printf("13. Write a program to find out whether a triangle is quadratic, isosceles or scalene.\n");
int s1,s2,s3;
scanf("%d%d%d",&s1,&s2,&s3);
}
if((s1==s2)||(s1==s3)||(s2==s3))
else
return 0;
#include<stdio.h>
#include<conio.h>
int main()
scanf("%c", &lowercaseChar);
if (islower(lowercaseChar))
uppercaseChar = toupper(lowercaseChar);
} else {
return 0;
}
#include<stdio.h>
#include<conio.h>
int main()
int i;
for(i=0;i<=100;i=i+2)
printf("%d\t",i);
return 0;
#include<stdio.h>
#include<conio.h>
int main()
int i;
for(i=1;i<=20;i=i+2)
printf("%d\t",i);
return 0;
}
17. To calculate sum of first 10 even numbers.
#include<stdio.h>
#include<conio.h>
int main()
int sum=0,i;
for(i=0;i<=10;i++)
sum=sum+i;
printf("%d",sum);
return 0;
#include<stdio.h>
#include<conio.h>
int main()
int num,i,f=1;
scanf("%d",&num);
if(num>0)
for
(i=1;i<=num;i++)
{
f=f*i;
return 0;
#include<stdio.h>
#include<conio.h>
int main()
scanf("%d",&num);
onum=num;
while(num !=0)
digit= num%10;
sum=sum+digit;
num=num/10;
return 0;
}
20. To display reverse of any number.
#include<stdio.h>
#include<conio.h>
int main()
scanf("%d",&num);
onum=num;
while(num!=0)
rem=num%10;
rev=rev*10+rem;
num=num/10;
return 0;
21. To find out sum of all numbers completely divisible by 5 among n numbers given by the user.
#include<stdio.h>
#include<conio.h>
int main()
printf("21. To find out sum of all numbers completely divisible by 5 among n numbers given by
the user.\n");
int n,i,sum = 0;
int num[n];
scanf("%d", &num[i]);
if (num[i]% 5 == 0)
sum =sum+num[i];
return 0;
#include<stdio.h>
#include<conio.h>
int main()
int i,num;
scanf("%d",&num);
if(num>0)
for(i=2;i<10;i++)
{
if(num%i==0)
else
return 0;
#include<stdio.h>
#include<conio.h>
int main()
int i,num;
for(i=2;i<100;i++)
if(i %2==0)
printf("%d\t",i);
return 0;
}
24. To check whether the entered number is Armstrong number or not.
#include<stdio.h>
#include<conio.h>
int main()
int num,rem,arm=0,onum;
scanf("%d",&num);
onum=num;
while(num!=0)
rem=num%10;
arm=arm+rem*rem*rem;
num=num/10;
if(onum==arm)
else
return 0;
25. To print natural number up to 10. Also, print its square value of each and find sum of them.
#include<stdio.h>
#include<conio.h>
int main()
printf("25. To print natural number up to 10. Also, print its square value of each and find sum of
them.\n");
sq=i* i;
sum=sum+sq;
return 0;
26. Write a C program to find the first and last digit of a number.
#include<stdio.h>
#include<conio.h>
int main()
printf("26. Write a C program to find the first and last digit of a number.\n");
scanf("%d", &number);
firstDigit = number;
return 0;
27. Write a C program to find sum of first and last digit of a number.
#include<stdio.h>
#include<conio.h>
int main()
printf("27. Write a C program to find sum of first and last digit of a number.\n");
scanf("%d", &number);
number=number/10;
firstDigit = number;
s=lastDigit+firstDigit;
return 0;
}
#include<stdio.h>
#include<conio.h>
int main()
scanf("%d",&num);
onum=num;
while(num !=0)
digit= num%10;
p=p+digit;
num=num/10;
return 0;
#include<stdio.h>
#include<conio.h>
int main()
scanf("%d", &num);
scanf("%d", &range);
return 0;
#include<stdio.h>
#include<conio.h>
int main()
int num,count = 0;
scanf("%d", &num);
if (num < 0)
{
num = -num;
while (num != 0) {
num=num/ 10;
count++;
return 0;
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
discriminant = b * b - 4 * a * c;
if (discriminant > 0)
else if (discriminant == 0)
else
realPart = -b / (2 * a);
return 0;