You are on page 1of 4

BCA-104 Programming in C (Practice Program)

Chapter 1 Programs:
// Program -->1
// Simple Program
#include <stdio.h>
void main()
{
clrscr();
printf("Hello!! How are you all\n");
printf("\n North Maharashtra Univerty");
getch();
}

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

// Program --> 2
// Use of Format specifier

#include <stdio.h>
void main()
{
int no,no1,no2;
float fno=89.342;
clrscr();
no=23450;
no1=4;
no2=21;
printf("\n The Value of NO = \n no=%d fno= %f no1= %d no2= %d
mul=%d",no,fno,no1,no2,no1*no2);

getch();
}
---------------------------------------------------------------

// Program --> 3
// Use of expression

#include <stdio.h>
void main()
{
int a,b;
char ch;
int mul;
clrscr();
printf("\n Enter the value A : ");
scanf("%d %d %c",&a,&b,&ch);
printf("\n A = %d \n B= %d",a,b);

printf("\n You entered %c",ch);


mul=a*b; //expression

1 |By Dr. Swati Phalak


BCA-104 Programming in C (Practice Program)
printf("\n Multiplication of %d and %d is %d",a,b,mul);
getch();
}
----------------------------------------------------------------

// Program --> 4
// Use of different data type variable

#include <stdio.h>
#include <conio.h>
void main()
{
int var=10;
float b=5.6;

clrscr();
printf("\n Value of var is %d and b is %d",var,b);
printf("\n Address of the var is %x and b is %x",&var,&b);

getch();
}

----------------------------------------------------------------
// Program --> 5
//Use of array to declare name

#include <stdio.h>
void main()
{
char ch;
char nm[20];
clrscr();
printf("\n Enter a string: ");
scanf("%c",&nm);

printf("\n String : %s",nm);


//printf("Char is : %c",ch);
getch();
}

----------------------------------------------------------------
// Program --> 6
// Use of getche(), getch(), getchar() function

#include <stdio.h>
void main()
{
char ch;
clrscr();
printf("\n enter a character : ");
getche();

2 |By Dr. Swati Phalak


BCA-104 Programming in C (Practice Program)
printf("\n Enter a char for getchar fun ");
ch = getchar();
printf(" \n You Entered : %c",ch);

getch();
}

----------------------------------------------------------------
// Program --> 7
//Use of getchar() and putchar()

#include <stdio.h>
void main()
{
char ch;
clrscr();
printf("\n Enter a Character : ");
ch=getchar();
printf("\nYou entered :");
putchar(ch);
getch();

----------------------------------------------------------------
// Program --> 8
//Use of getch() and putch() function
#include <stdio.h>
void main()
{
char ch;
clrscr();
printf("\n Enter a Character : ");
ch=getch();
printf("\nYou entered :");
putch(ch);
getch();

----------------------------------------------------------------
// Program --> 9
// Use of gets() and puts() function
#include <stdio.h>
void main()
{
char nm[20];
clrscr();
printf("\n Enter string using gets : ");
gets(nm);

3 |By Dr. Swati Phalak


BCA-104 Programming in C (Practice Program)
printf("\n You Entered : ");
puts(nm);
getch();
}

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

4 |By Dr. Swati Phalak

You might also like