Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

1.

TO DISPLAY A SIMPLE LINE

#include<stdio.h>
#include<conio.h>
void main ( )
{
clrscr ( );
printf(”hello”);
getch ();
}

2. ADD TWO NO.

#include<stdio.h>
#include<conio.h>
void main ( )
{
int a, b, c;
clrscr ( );
printf(”enter a number=”);
scanf(“%d”,& a);
printf(”enter another number=”);
scanf(“%d”,& b);
c=a+b;
printf(“the ans is=%d”,c);
getch();
}
3. TO ACCEPT DAYS AND DISPLAY THEM IN THE FORMAT MONTHS
AND DAYS. (45DAYS=1MONTHS 15 DAYS).

#include<stdio.h>

#include<conio.h>

void main ( )

int d, m, y;

clrscr ( );

printf(”enter the no of days=”);


scanf(“%d”,& y);

d=y%30;

m=y/30;

printf(“the month is=%d”,m);

printf(”days=%d”,d);

getch();

}
4. TO DISPLAY PRINCIPLE AMOUNT

#include<stdio.h>

#include<conio.h>

void main ( )

float d,p,r;

int t;

clrscr ( );

printf(“enter principal amount=”);

scanf(“%f”,&p);

printf(”enter rate of interest=”);

scanf(“%f”,&r);

printf(”enter time=”);

scanf(“%d”,&t);

d=p*r*t/100;

printf(”the simple interest is=%f”,d);

getch();

}
5. IF STATEMENT.

#include<stdio.h>

#include<conio.h>

void main ( )

int mark;

clrscr( );

printf(”enter marks of a student=”);

scanf(“%d”,& mark);

if (mark>300)

printf(’’the student has passed’’);

getch ();

6. TO SHOW PASSED OR FAIL USING IF ELSE.

#include< stdio.h>

#include<conio.h>

void main ( )

int mark;

clrscr( );

printf(”enter marks of a student=”);


scanf(“%d”,& mark);

if (mark>300)

printf(’’the student has passed’’);

else

printf(’’the student has fail’’);

getch ();

8. TO SHOW POSITIVE AND NEGETIVE NO.

#include< stdio.h>

#include<conio.h>

void main ( )

int a;

clrscr( );

printf(”enter the no=”);

scanf(“%d”,& a);

if(a>0)
printf(”the no.is positive’’);
else
printf(”the no.is negetive’’);
getch( );

}
9. WRITE A PROGRAM TO DISPLAY A MULTIPLICATION

#include<stdio.h>
#include<conio.h>
void main ( )
{
int i, a, b;
clrscr ( );
printf(”enter a number=”);
scanf(“%d”,& a);
for(i=1;i<=10;i++)
{
b=a*i;
printf(“\n the result is=%d”,b);
}
getch();
}

10. WRITE A PROGRAM TO DISPLAY THE EVEN NO BETWEEN 1-20 USING WHILE LOOP.

#include<stdio.h>
#include<conio.h>
void main ( )
{
Int i=1;

Clrscr();

While(i<=20)
{

If(i%2==0)

Printf(“\n the even no are=%d”,i);

i++;

getch();

11. WRITE A PROGRAM TO DISPLAY THE EVEN NO BETWEEN 1-20 USING DO WHILE LOOP.

#include<stdio.h>
#include<conio.h>
void main ( )
{
int i=0;

Clrscr();

do

If(i%2==0)

Printf(“\n the even no are=%d”,i);

i++;

}while (i<=20);

getch();

}
12. WRITE A PROGRAM TO DISPLAY SUM OF 10 NO. USING

#include<stdio.h>
#include<conio.h>
void main ( )
{
int i,sum=0,a[10];
clrscr();
for(i=0;i<=9;i++)
{
printf(“enter values=”);
scanf(“%d”,& a[i]);
sum=sum+a[i];
}
printf(“the sum=%d”,sum);
getch();
}

You might also like