Basic programs for the begineers :-
Lab Practical programs for BCA, B-tech,IT.

Here are some programs which help the begineers to understand the  basic programming .

1. Program to print the table of any number  using c language.
2. Program to calculate the simple interest.
3. Program to  convert temperature fahrenheit to celsius.
4.Program to convert celsius into Fahrenheit.
5. Program to convert centimeter to meter.
6. Program to calculate the area of square and rectangle.
7.Program to find the perimeter of square and rectangle.
8. Program to calculate the area and perimeter of circle.
9. Program to calculate the result of a student  of  four subject.
9. Program to  implement realtional  operatror  in C language.
10. Program to find the sum of five digit.
11. Program to congurance modulo.
12. Program  to reverse five digit number.
OR
Program to calculate the sum of five digit number.
13.Program to check the given five digit number is pailandrom or   not.
14. Program to  use sizeof() function.
15.Program to swap to value using third variable.
16.Program to interchange two variable with out taking 3rd variable
17. Program for using comma operator.
18 . Program to check  whether the given year is leap or not.
19.Program to check whether the given number is odd or even.
20.  Program to check the equality between numbers.
21.Program to check the given  char is vowel or not.
22. Program to print the ASCII value of any character.
23. Program to check whether the given character is digit,alphabet, special symbol.
24. Program to change upper case to lower case vice-versa.
25.Program  to check the division of a student  .

## 1. Program to print the table of any number  using c language.

Solution.

#include<stdio.h>
#include<conio.h>

void main()
{
int a,b,i;
printf("\nenter the number:-");
printf("\ntable of the given a is:-");
scanf("%d",&a);
clrscr();
for(i=1;i<=10;i++)
{
b=a*i;
printf("\n %d* %d=%d",a,i,b);
getch();
}
}

## 2. Program to calculate the simple interest.

Solution.

#include<stdio.h>
#include<conio.h>
void main()
{
int p,r,si;
int t;
clrscr();
printf("enter princpal");
scanf("%d",&p);
printf("enter rate");
scanf("%d",&r);
printf("enter time");
scanf("%d",&t);
si=(p*r*t)/100;
printf("\n simple interest of %d, %d and %d=%d",p,r,t,si);
getch();
}

## 3. Program to  convert temperature fahrenheit to celsius.

Solution.
//convert temp fer into cen

#include<stdio.h>
#include<conio.h>
void main()
{
float fer,cen;
clrscr();
printf("enter tempeture in Fahrenheit");
scanf("%f",& fer);
cen=(fer-32)*(5/9);
printf("%f F=%f c",fer,cen);
getch();
}

## 4.Program to convert celsius into Fahrenheit.

Solution.

// covnert temp cen into fer

#include<stdio.h>
#include<conio.h>
void main()
{
float cen, fer;
clrscr();
printf("enter temperature in Celsius");
scanf("%f",& cen);
fer=cen*(9/5)+32;
printf("%f of C=%f F",cen, fer);
getch();
}

## 5. Program to convert centimeter to meter.

Solution.

//convetr cm into m
#include<stdio.h>
#include<conio.h>
void main()
{
int cm,m;
clrscr();
printf("enter length in cm");
scanf("%d",&cm);
m=cm/100;
printf("cm into m %d=%d",cm,m);
getch();
}

## 6. Program to calculate the area of square and rectangle.

Solution.

//area of squre and reactangle
#include<stdio.h>
#include<conio.h>
void main()
{
float l,w,s,a;
clrscr();
printf("enter length and widht of rectangle");
scanf("%f%f",&l,&w);
a=l*w;
printf("area of rectangle=%f",a);
printf("\nenter side of square");
scanf("%f",&s);
a=s*s;
printf("\narea of square=%f",a);
getch();
}

## 7.Program to find the perimeter of square and rectangle.

Solution.

//perimeter of squre and rectangle
#include<stdio.h>
#include<conio.h>
void main()
{
float l,b,p1,s,p2;
clrscr();
printf("enter lenght of rectangle");
scanf("%f",&l);
scanf("%f",&b);
p1=2*(l+b);
printf("\n perimeter of rectangle=%f",p1);
printf("\n enter side of square");
scanf("%f",&s);
p2=4*s;
printf("\n perimeter of square=%f",p2);
getch();
}

## 8. Program to calculate the area and perimeter of circle.

Solution

//area and perimeter of circle
#include<stdio.h>
#include<conio.h>
void main()
{
float r,a,p;
clrscr();
scanf("%f",&r);
a=3.14*r*r;
printf("\n area of circle=%f",a);
p=2*3.14*r;
printf("\n perimeter of circle=%f",p);
getch();
}

## 9. Program to calculate the result of a student  of  four subject.

Solution.

//result
#include<stdio.h>
#include<conio.h>
void main()
{
float h,e,m,s,t,p;
clrscr();
printf("enter hindi marks");
scanf("%f",&h);
printf("enter english marks");
scanf("%f",&e);
printf("enter maths marks");
scanf("%f",&m);
printf("enter scince marks");
scanf("%f",&s);
t=h+e+m+s;
p=(t/400)*100;
printf("\n Hindi   %f ",h);
printf("\n English %f ",e);
printf("\n Maths %f ",m);
printf("\n Scince %f ",s);
printf("\n total no %f ",t);
printf("\n percentage %f ",p);
getch();
}

## 9. Program to  implement realtional  operatror  in C language.

Solution.

//for relational operator

#include<stdio.h>
#include<conio.h>
void main()
{
int a=3,b=6,c=9,d=3,x;
clrscr();
x=(a>b);
printf("%d",x);
x=(b<c);
printf("\n %d",x);
x=(a==d);
printf("\n %d",x);
x=(a!=b);
printf("\n %d",x);
getch();
}

## 10. Program to find the sum of five digit.

Solution.

//sum of 5 digit no
#include<stdio.h>
#include<conio.h>
void main()
{
long num,R1,R2,R3,R4,R5,sum;
clrscr();
printf("enter any 5 digit no");
scanf("%ld",&num);
R1=num%10;
num=num/10;
R2=num%10;
num=num/10;
R3=num%10;
num=num/10;
R4=num%10;
num=num/10;
R5=num%10;
num=num/10;
sum=R1+R2+R3+R4+R5;
printf("sum=%ld",sum);
getch();
}

## 11. Program to congurance modulo.

Solution.
//congurance modulo
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter no");
scanf("%d",&b);
a=b%4;
printf("%d mod 4= %d",b,a);
getch();
}

## Program to calculate the sum of five digit number.

Solution .

//for reversing the 5 digit no
#include<stdio.h>
#include<conio.h>
void main()
{
long num,R1,R2,R3,R4,R5,sum,RN;
clrscr();
printf("enter any 5 digit no");
scanf("%ld",&num);
R1=num%10;
num=num/10;
R2=num%10;
num=num/10;
R3=num%10;
num=num/10;
R4=num%10;
num=num/10;
R5=num%10;
num=num/10;
sum=R1+R2+R3+R4+R5;
printf("sum=%ld",sum);
RN=(R1*10000)+(R2*1000)+(R3*100)+(R4*10)+(R5*1);
printf("\nreverse of the given 5 digit no=%ld",RN);
getch();
}

## 13.Program to check the given five digit number is pailandrom or   not.

Solution.

//to check whether the given 5 digit no is pailandrom or not
#include<stdio.h>
#include<conio.h>
void main()
{
long num,R1,R2,R3,R4,R5,RN,num1;
clrscr();
printf("enter any 5 digit no");
scanf("%ld",&num);
num1=num;
R1=num%10;
num=num/10;
R2=num%10;
num=num/10;
R3=num%10;
num=num/10;
R4=num%10;
num=num/10;
R5=num%10;
num=num/10;
RN=(R1*10000)+(R2*1000)+(R3*100)+(R4*10)+(R5*1);
printf("Reverse of the number=%ld",RN);
if(num1==RN)
{
printf("\nthe given 5 digit no is pailandrom");
}
else
{
printf("\nthe given 5 digit no is not pailaindrom");
}
getch();
}

## 14. Program to  use sizeof() function.

Solution.

//for range
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
float b;
printf ("size of integer=%d",sizeof (a));
printf ("\n size of float=%d",sizeof (b));
printf ("\n size oflong=%d",sizeof(long));
printf("\n size of character=%d",sizeof(char));
getch();

## 15.Program to swap to value using third variable.

Solution.

//interchanging the 2 values by taking 3 variable
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("enter the valuue of a&b");
scanf("%d%d",&a,&b);
c=a;
a=b;
b=c;
printf("\nafter swaping a=%d and b=%d",a,b);
getch();
}

## 16.Program to interchange two variable with out taking 3rd variable

Solution.

//for interchange with 2 variable with out taking 3rd variable
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter value of a&b");
scanf("%d,%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("\nafter swap a=%d and b=%d",a,b);
getch();
}

## 17. Program for using comma operator.

Solution.

//for using comma operator
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
float x,y;
a=10, b=20;
c=a+b*10/5 - 2%5;
printf("%d%d%d",a,b,c);
getch;
}

## 18 . Program to check  whether the given year is leap or not.

Solution.

//leap year or not
#include<stdio.h>
#include<conio.h>
void main()
{
int year;
clrscr();
printf("Enter year ");
scanf("%d",&year);
if((year%4==0)&&(year%100!=0)||(year%400==0))
printf("leap year");
else
printf("not a leap year");
getch();

## 19.Program to check whether the given number is odd or even.

Solution.

//check even or odd
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("Enter number");
scanf("%d",&n);
if(n%2==0)
printf("number is even");
else
printf("number is odd");
getch();
}

## 20.  Program to check the equality between numbers.

Solution.

//greater  no between two
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter any 3no");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(a>c))
printf("%d is greater",a);
else if((b>a)&&(b>c))
printf("%d is greater",b);
else
printf("%d is greater",c);
getch();

## 21.Program to check the given  char is vowel or not.

Solution .

#include<stdio.h>
#include<conio.h>
void main()
{
char key;
clrscr();
printf("press any key");
scanf("%c",&key);
if((key=='a')||(key=='e')||(key=='i')||(key=='o')||(key=='u')||(key=='A')||(key=='E')||(key=='I')||(key=='O')||(key=='U'))
printf("%c is vowel",key);
else
printf("not vowel");
getch();
}

## 22. Program to print the ASCII value of any character.

Solution.

//AscII value of any character
#include<stdio.h>
#include<conio.h>
void main()
{
char key;
clrscr();
printf("press any key");
scanf("%c",&key);
printf("ASCII value of %c=%d",key,key);
getch();
}

## 23. Program to check whether the given character is digit,alphabet, special symbol.

Solution.

//check whther alpabet digit, special symbol
#include<stdio.h>
#include<conio.h>
void main()
{
char key;
clrscr();
printf("press any key");
scanf("%c",&key);
if((key>=65)&&(key<=90))
printf("%c is an upper case character",key);
else

if((key>=97)&&(key<=122))
printf("%c is lower case character",key);
else

if((key>=48)&&(key<=57))
printf("%c is a digit",key);
else
printf("%c is a special character",key);
getc

h();
}

## 24. Program to change upper case to lower case vice-versa.

Solution.

//chnage upeer case to lowercase and vice verse
#include<stdio.h>
#include<conio.h>
void main()
{
char key;
clrscr();
printf("press any key");
scanf("%c",&key);
if((key>=65)&&(key<=90))
{
key=key+32;
printf("after change key=%c",key);
}
else if((key>=97)&&(key<=122))
{
key=key-32;
printf("after change key=%c",key);
}
else
printf("%c is not a alpebet",key);
getch();

## 25.Program  to check the division of a student  .

Solution.

//check division
#include<stdio.h>
#include<conio.h>
void main()
{
int per;
clrscr();
printf("enter percentage of student");
scanf("%d",&per);
if(per>=60)
printf("1st division");
else if(per>45)
printf("2nd division");
else if(per>33)
printf("3rd division");
else
printf("fail");
getch();
}