Professional Documents
Culture Documents
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);
// 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);
----------------------------------------------------------------
// Program --> 6
// Use of getche(), getch(), getchar() function
#include <stdio.h>
void main()
{
char ch;
clrscr();
printf("\n enter a character : ");
getche();
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);
----------------------------------------------------------------