Professional Documents
Culture Documents
PROGRAM: 1
AIM: - Write a C Program to Print a String.
FLOWCHART: -
STAR
T
Print=”HELL
O WORLD”
STOP
PROGRAM: -
#include<stdio.h>
#include<conio.h>
void main()
{
printf("Hello world");
getch();
}
OUTPUT: -
stop
PARMINDER K, 813/22, BTPS102-18
PROGRAM: 2
AIM: - To Observe Difference Between /n and \n.
FLOWCHART: -
STAR
T
Print=”nn\n\
nn”
Print=”nn/
n/nn”
PROGRAM: - STOP
#include<stdio.h>
#include<conio.h>
void main()
{
printf("nn\n\nn\n");
printf("nn/n/nnn/n");
getch();
}
OUTPUT: -
stop
PARMINDER K, 813/22, BTPS102-18
PROGRAM: 3
AIM: - To Print Sum of Two Numbers.
FLOWCHART: -
START
Declare a, b,
sum
Read
numbers
Sum=a + b
Print
sum
END
PROGRAM: -
#include<stdio.h>
#include<conio.h>
void main(){
int a, b,sum;
clrscr();
a=5, b=8
sum=a+b;
printf("%d",sum);
getch();
OUTPUT: -
stop
PARMINDER K, 813/22, BTPS102-18
PROGRAM: 4
AIM: - To get two values from user and add the numbers.
FLOWCHART: -
STAR
T
Input
a,b
sum=a+b
Print sum
End
PROGRAM:-
#include<stdio.h>
#include<conio.h>
void main()
int a,b,sum;
clrscr();
scanf("%d", &a);
stop
PARMINDER K, 813/22, BTPS102-18
scanf("%d", &b);
sum=a+b;
getch();
OUTPUT: -
PROGRAM: 5
AIM: - To Calculate Simple Interest.
stop
PARMINDER K, 813/22, BTPS102-18
FLOWCHART: -
START
Input: P,
R. T
Calculate:-
SI=(P*R*T)/
100
Print=Si
PROGRAM: - mple
Interest
#include<stdio.h>
#include<conio.h>
float p,r,t,interest;
clrscr();
scanf("%f", &p);
scanf("%f", &r);
scanf("%f", &t);
stop
PARMINDER K, 813/22, BTPS102-18
interest=(p*r*t)/100;
getch();
OUTPUT: -
PROGRAM: 6
AIM: - To Implement Math Functions.
FLOWCHART: - START
stop
Input a
PARMINDER K, 813/22, BTPS102-18
PROGRAM: -
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
float a,b,c;
clrscr();
scanf("%f",&a);
b=sqrt(a);
c=pow(a,3);
getch();
stop
PARMINDER K, 813/22, BTPS102-18
OUTPUT: -
PROGRAM: 7
AIM: - To find largest of two no. using IF-ELSE condition.
FLOWCHART: -
start
stop
PARMINDER K, 813/22, BTPS102-18
input a,b
is
No a>b Yes
stop
PROGRAM: -
#include<stdio.h>
#include<conio.h>
void main()
float a,b;
clrscr();
scanf("%f",&a);
scanf("%f",&b);
if (a>b)
printf("%f is greater",a);
else
10
stop
PARMINDER K, 813/22, BTPS102-18
printf("%f is greater",b);
getch();
OUTPUT: -
PROGRAM: 8
AIM: - To find largest of three no. using IF-ELSE condition.
FLOWCHART: -
Start
11
stop
PARMINDER K, 813/22, BTPS102-18
PROGRAM: -
void main(){
If a>b
float a,b,c;
scanf("%f", &c);
else if (b>c)
End
printf("%f is the greatest", b);
else
getch();
OUTPUT: -
12
stop
PARMINDER K, 813/22, BTPS102-18
PROGRAM: 9
AIM: - To Print First 10 Natural Numbers using a loop.
FLOWCHART: -
Star
t
Input n
I=1
i>
n
Print i
i=i+1
End
13
stop
PARMINDER K, 813/22, BTPS102-18
PROGRAM: -
#include<stdio.h>
#include<conio.h>
void main()
int i;
clrscr();
printf("%d",i);
getch();
OUTPUT: -
14
stop
PARMINDER K, 813/22, BTPS102-18
PROGRAM: 10
AIM: - To Print Even Numbers Till 10 using a loop.
FLOWCHART: -
Start
Count=2
Count=co
unt+2
Is
count<=
10
END
PROGRAM: -
15
stop
PARMINDER K, 813/22, BTPS102-18
#include<stdio.h>
#include<conio.h>
void main()
int i;
clrscr();
printf("%d",i);
getch();
OUTPUT:-
PROGRAM: 11
16
stop
PARMINDER K, 813/22, BTPS102-18
FLOWCHART: -
Start
Input i
J=1
Is Outp J=j+1
j<=10 ut=i*j
End
PROGRAM:-
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
clrscr();
printf("table of n=");
scanf("%d",&n);
for(i=0 ; i<=10 ; i++)
printf("%d * %d - %d\n",n,i,n*i);
getch();
}
17
stop
PARMINDER K, 813/22, BTPS102-18
OUTPUT:-
PROGRAM: 12
AIM: - To Check Whether A Number Is Prime or Not.
FLOWCHART: -
18
stop
PARMINDER K, 813/22, BTPS102-18
Start
Read
n
I=2
I<n
N
%i==
I=i+1
I==
n
Print Print=
=no.is no. is
prime not
prime
End
PROGRAM:-
#include<stdio.h>
#include<conio.h>
void main(){
clrscr();
int a,b=0,c,d;
printf("enter any number=");
scanf("%d",&a);
19
stop
PARMINDER K, 813/22, BTPS102-18
for(c=2;c<a;c++)
{
d=a%c;
if(d==0)
{
b=1;
}
}
if(b==0)
{
printf("the number entered is prime number");
}
else
{
printf("the number entered is not prime number");
}
getch();
}
OUTPUT:-
PROGRAM: 13
AIM: - To Print Fibonacci Series.
FLOWCHART:-
20
stop
PARMINDER K, 813/22, BTPS102-18
start
i=2
NO i<= n YES
Show =a + b
a=b
b =show , ++ i
pri
PROGRAM:-
#include<stdio.h>
#include<conio.h>
void main()
int i,n;
21
stop
PARMINDER K, 813/22, BTPS102-18
clrscr();
scanf("%d",&n);
printf("%d ",t1);
next_t=t1+t2;
t1=t2;
t2=next_t;
getch();
OUTPUT:-
PROGRAM: 14
AIM: - To Check Whether A Number Is Palindrome or Not.
FLOWCHART:-
start
22
stop
PARMINDER K, 813/22, BTPS102-18
Read num
Reverse =0
Tempnum = num
Num i =0 No
Yes
Reverse* = 10 + rem
Reverse = Tempnum
Yes No
Stop
PROGRAM:-
#include<stdio.h>
#include<conio.h>
void main(){
scanf("%d",&n);
23
stop
PARMINDER K, 813/22, BTPS102-18
orig=n;
while(n!=0)
rem=n%10;
rev=rev*10 + rem;
n=n/10;
if(orig == rev)
else
getch();
OUTPUT:-
PROGRAM: 15
AIM: - Calculate Operation using switch statement
FLOWCHART:-
24
stop
PARMINDER K, 813/22, BTPS102-18
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
float s,a,b,sub,m,d,sq;
int ch,v=1;
clrscr();
while(v==1)
scanf("%f%f",&a,&b);
printf("enter \n 1 for addition \n 2 for substraction \n 3 for multiplication \n 4 for division \n 5 for
square root value \n 6 for exit \n ");
scanf("%d",& ch);
switch(ch)
case 1:
s=a+b;
25
stop
PARMINDER K, 813/22, BTPS102-18
printf(" %f",s);
break;
case 2:
sub=a-b;
printf("%f",sub);
break;
case 3:
m= a*b;
printf("%f",m);
break;
case 4:
d=a/b;
printf("%f",d);
break;
case 5:
sq=sqrt(a);
printf("%f",sq);
break;
default:
printf("invalid choice");
break;
scanf("%d",&v);
getch();
26
stop
PARMINDER K, 813/22, BTPS102-18
OUTPUT: -
27
stop
PARMINDER K, 813/22, BTPS102-18
PROGRAM: 16
AIM: - Right triangle star pattern in C
SOFTWARE USED: - Turbo C (Version 3.0)
FLOWCHART:-
PROGRAM: -
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows");
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
printf("* ");
}
printf("\n");
}
return 0;
28
stop
PARMINDER K, 813/22, BTPS102-18
OUTPUT:-
PROGRAM: 17
AIM: -To print a given number pattern.
SOFTWARE USED:-Turbo C (Version 3.0)
FLOWCHART:-
PROGRAM:-
#include <stdio.h>
int main()
{
int i, j,,N;
printf(“enter N :”);
29
stop
PARMINDER K, 813/22, BTPS102-18
scanf(“%d”,&N);
for(i=1;i<=N;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
return 0;
}
Output :-
PROGRAM: 18
AIM: - Program to print pyramid.
30
stop
PARMINDER K, 813/22, BTPS102-18
31
stop
PARMINDER K, 813/22, BTPS102-18
PROGRAM:-
#include <stdio.h>
#include <conio.h>
void main()
{
int i, j, rows, k = 0;
printf (" Enter a number to define the rows: \n");
scanf ("%d", &rows);
for ( i =1; i <= rows; i++)
{
for ( j = 1; j <= rows - i; j++)
{
printf (" ");
}
// use for loop where k is less than equal to (2 * i -1)
for ( k = 1; k <= ( 2 * i - 1); k++)
{
printf ("* "); // print the Star
}
printf ("\n");
}
getch();
}
OUTPUT:-
PROGRAM: 19
AIM:-Factorial program using a loop.
FLOWCHART:-
32
stop
PARMINDER K, 813/22, BTPS102-18
PROGRAM:-
#include<stdio.h>
int main()
{
int i,fact=1,number;
printf("Enter a number: ");
scanf("%d",&number);
for(i=1;i<=number;i++){
fact=fact*i;
}
printf("Factorial of %d is: %d",number,fact);
return 0;
}
OUTPUT :-
33
stop