Pic Print
Pic Print
FLOWCHART:
start
Read units
Yes Units No
c=100
Amount=100*0
Unit< NO
=200
YES
Amount=(100*0)+
(Unit-100)*1.5 Unit<
=500
Amount(100*0)+(200- YES No
100)+(unit-300)*2
Amount[100*0]+[200-100]*35+
[500-200]*4.64(unit-500]*6.6
Print amount
Stop
RESULT:
ARITHMATIC OPEARTION
FLOWCHART:
RESULT:
RETAIL SHOP BILLING
FLOWCHART:
Start
Tax=0.28
Display
Items,Rate_of_item
Read Quantity
Stop
RESULT:
WEIGHT OF A STEEL BAR
FLOWCHART:
RESULT:
SINE SERIES
FLOWCHART:
Start
Read x, n
x = x * 3.14/ 180
t=x
sum = x
t =(t*(-1)*x*x)/(2*i*(2*i+1));
sum=sum+t;
Stop
RESULT:
COMPUTE ELECTRICAL CURRENT IN THREE PHASE AC CIRCUIT
FLOWCHART:
RESULT:
PRINTING STUDENT NAME AND COLLEGE NAME
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
printf(“ANBU\n”);
printf(“RVSCET”);
getch();
}
OUTPUT:
ANBU
RVSCET
RESULT:
AREA CALCULATION OF VARIOUS SHAPES
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
float r,l,b,s,h;
float circle,rectangle,square,triangle;
printf("enter the numbers:");
scanf("%f%f%f%f%f",&r,&l,&b,&s,&h);
circle=(22*r*r)/7;
printf("\narea of the circle is:%f",circle);
rectangle=l*b;
printf("\narea of the rectangle is:%f",rectangle);
square=s*s;
printf("\narea of the square is:%f",square);
triangle=(b*h)/2;
printf("\narea of the triangle is:%f",triangle);
getch();
}
OUTPUT:
RESULT:
FIND THE ROOTS OF A QUADRATIC EQUATION
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,d,r1,r2;
clrscr();
printf(“\nEnter the values of a,b and c”);
scanf(“%f%f%f”,&a,&b,&c);
d=b*b-4*a*c;
r1=(-b+sqrt(d))/(2*a);
r2=(-b-sqrt(d))/(2*a);
printf(“The root1 and root2 of a=%f b=%f c=%f is \n %f \n %f“,a,b,c,r1,r2);
getch();
}
OUTPUT:
Enter the values of a,b and c
7
35
9
The root1 and root2 of a=7 b=35 c=9 is
-0.271932
-4.728068
RESULT:
.
FIND THE GIVEN NUMBER IS ODD OR EVEN
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int number;
clrscr();
printf(“\nEnter the number”);
scanf(“%d”,&number);
if(number%2==0)
{
printf(“\nThe number is even number”);
}
else
{
printf(“\nThe number is odd number”);
}
getch();
}
OUTPUT:
Enter the number
5
The number is odd number
Enter the number
4
The number is even number
RESULT:
FIND THE LARGEST OF THREE NUMBERS
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf(“\nEnter the numbers a,b and c”);
scanf(“%d %d%d”,&a,&b,&c);
if(a>b)
{
if(a>c)
printf(“\n%d is largest number”,a);
else
printf(“\n%d is largest number”,c);
}
else
{
if(b>c)
printf(“\n%d is largest number”,b);
else
printf(“\n%d is largest number”,c);
}
getch();
}
OUTPUT:
RESULT:
.
MULTIPLICATION TABLE FOR THE GIVEN NUMBER
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int table;
int i,count;
clrscr();
printf("Enter the number of table you want to print\n");
scanf("%d",&table);
printf("Result:\n");
for(i=1;i<=10;i++)
{
printf("%d * %d =%d\n",i,table,i*table);
}
getch();
}
OUTPUT:
Enter the number of tables you want to print:2
Result:
1* 2=2
2*2=4
3*2=6
4*2=8
5*2=10
6*2=12
7*2=14
8*2=16
9*2=18
10*2=20
RESULT:
FIRST N NUMBERS DIVISIBLE BY 5
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
printf("\n Enter the number of terms:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(i%5==0)
{
printf("\t%d",i);
}
}
getch( );
}
OUTPUT:
Enter the number of terms: 50
5 10 15 20 25 30 35 40 45 50
RESULT:
PALINDROME USING INTEGERS
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int n,result=0,sum=0,e;
clrscr();
printf("Enter no:");
scanf("%d",&n);
e=n;
while(n>0) {
result =n%10;
sum =sum *10+result;
n=n/10;
}
if(e==sum)
printf("It ia a Palindrome"); else
printf("It is not a palindrome");
getch();
}
OUTPUT:
Enter no:121
It is a Palindrome
Enter no: 345
It is not a palindrome
RESULT:
CHECKING PRIME NUMBER
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,c=0,i,n;
clrscr();
printf(" Enter the no to be checked:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
a=n%i;
if(a==0)
{
c=c+1;
}
}
if(c==2)
{
printf(" It is a prime number");
}
else
{
printf(" It is not a prime number");
}
getch( );
}
OUTPUT:
Enter a no to be checked: 6
It is not a prime number
Enter a no to be checked: 5
It is a prime number
RESULT:
FIBONACCI NUMBER
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int f,f1=-1,f2=1,x,a;
clrscr();
printf("Enter a no:");
scanf("%d",&n);
for(a=0;a<n;a++)
{
f=f1+f2;
f1=f2;
f2=f;
printf("\n%d",f);
}
getch();
}
OUTPUT:
Enter a no: 5
01123
RESULT:
ASCENDING/ DESCENDING ORDER
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],n,i,j,temp;
clrscr();
printf("Enter the no of values");
scanf("%d",&n);
printf("Enter the elements one by one\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}}}
printf("\n Ascending order");
for(i=0;i<n;i++)
printf("\t%d",a[i]);
printf("\n Descending order");
for(i=n-1;i>=0;i--)
printf("\t%d",a[i]);
getch();
}
OUTPUT:
RESULT:
MATRIX ADDITION
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j;
clrscr();
printf(“Enter the values of Matrix A : \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“Enter the values of Matrix B : \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&b[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf(“Resultant Matrix:\n”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“%d\t”,c[i][j]);
}
printf(“\n”);
}
getch();
}
OUTPUT:
2 2 2
2 2 2
2 2 2
2 2 2
2 2 2
2 2 2
Resultant Matrix:
4 4 4
4 4 4
4 4 4
RESULT:
MATRIX MULTIPLICATION
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j,k;
clrscr();
printf(“Enter the values of Matix A : \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“Enter the values of Matix B : \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&b[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=0;
for(k=0;k<m;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf(“Resultant Matrix\n”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“%d\t”,c[i][j]);
}
printf(“\n”);
}
getch();
}
OUTPUT:
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
Resultant Matrix:
2 4 6
8 10 12
14 16 18
RESULT:
PROGRAM TO FIND TRANSPOSE OF MATRIX
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],i,j;
clrscr();
printf(“Enter the values in array : \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“\nTranspose of given matrix : \n”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“%d\n”,i,j,a[j][i]);
}
}
getch();
OUTPUT:
1 2 3
4 5 6
7 8 9
Transpose of given matrix:
1 4 7
2 5 8
3 6 9
RESULT:
FACTORIAL USING RECURSIVE FUNCTION
PROGRAM:
#include<stdio.h>
#include<conio.h>
int fact(int);
int main()
{
int a;
clrscr();
printf("\nEnter the number:");
scanf("%d",&a);
printf("The factorial of %d! is %d",a,fact(a));
}
int fact(int x)
{
int f;
if(x==1)
return(1);
else
f=x*fact(x-1);
return(f);
}
OUTPUT:
RESULT:
STRING FUNCTIONS
Program:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[50],str1[50];
int l;
clrscr();
RESULT:
PALINDROME USING STRINGS
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char s1[15],s2[15];clrscr( );
printf("\nEnter the string:");
scanf("%s",s1);
strcpy(s2,s1);
strrev(s1);
if(strcmp(s1,s2)==0)
printf("\n The string is palindrome");
else
printf("\n The string is not a palindrome");
getch();
}
OUTPUT:
Enter the string:ece
The string is palindrome
Enter the string:cse
The string is not a palindrome
RESULT:
COUNT THE NUMBER OF VOWELS, CONSONANTS DIGITS AND WHITE SPACES
PRESENT IN A LINE OF TEXT
PROGRAM:
#include<stdio.h>
#include<conio.h>
int main()
{
char line[150];
int i, vowels, consonants, digits, spaces;
clrscr();m
vowels = consonants = digits = spaces = 0;
printf("Enter a line of string: ");
scanf("%[^\n]", line);
for(i=0; line[i]!='\0'; ++i)
{
if(line[i]=='a' || line[i]=='e' || line[i]=='i' ||
line[i]=='o' || line[i]=='u' || line[i]=='A' ||
line[i]=='E' || line[i]=='I' || line[i]=='O' ||
line[i]=='U')
{
++vowels;
}
else if((line[i]>='a'&& line[i]<='z') || (line[i]>='A'&& line[i]<='Z'))
{
++consonants;
}
else if(line[i]>='0' && line[i]<='9')
{
++digits;
}
else if (line[i]==' ')
{
++spaces;
}
}
printf("Vowels: %d",vowels);
printf("\nConsonants: %d",consonants);
printf("\nDigits: %d",digits);
printf("\nWhite spaces: %d", spaces);
getch();
return 0;
}
OUTPUT:
RESULT:
SWAPPING TWO NUMBERS USING CALL BY VALUE AND CALL BY REFENCE
PROGRAM:
Call by value:
#include <stdio.h>
#include<conio.h>
int add(int,int);
int main()
int a,b,c;
clrscr();
scanf("%d%d",&a,&b);
c=add(a,b);
printf("\nSum is:%d",c);
int z;
z=x+y;
return(z);
}
Call by reference:
#include <stdio.h>
#include<conio.h>
void swap(int*,int*);
void main()
{
int x,y;
printf("\nEnter value of x:");
scanf("%d",&x);
printf("\nEnter value of y:");
scanf("%d",&y);
swap(&x,&y);
printf("\nx=%d,y=%d",x,y);
{
int c;
c=*a;
*a=*b;
*b=c;
printf("\nx=%d,y=%d",*a,*b);
}
OUTPUT:
Call by value:
Sum is:13
OUTPUT:
Call by reference:
x=6,y=5
RESULT:
MARKSHEET OF ‘N’ STUDENTS USING STRUCTURES
PROGRAM:
#include<stdio.h>
#include<conio.h>
struct student
{
char name[10][10];
int rollno,m1,m2,m3,total;
};
void main()
{
int num,i,j;
struct student s1[10];
clrscr();
printf("Enter the number of students");
scanf("%d",&num);
for(i=0;i<num;i++)
{
printf("Enter the roll number\n");
scanf("%d",&s1[i].rollno);
printf("Enter the name \n");
scanf("%s",&s1[i].name);
printf("Enter the mark1\n");
scanf("%d",&s1[i].m1);
printf("Enter the mark2\n");
scanf("%d",&s1[i].m2);
printf("Enter the mark3\n");
scanf("%d",&s1[i].m3);
s1[i].total=s1[i].m1+s1[i].m2+s1[i].m3;
}
printf("The details of the mark list is as follows \n");
printf("\nRollno");
printf("\tName ");
printf("\tMark1");
printf("\tMark2");
printf("\tMark3");
printf("\tTotal");
printf("\n");
for(i=0;i<num;i++)
{
printf("\n%d",s1[i].rollno);
printf("\t%s",s1[i].name);
printf("\t%d",s1[i].m1);
printf("\t%d",s1[i].m2);
printf("\t%d",s1[i].m3);
s1[i].total=s1[i].m1+s1[i].m2+s1[i].m3;
printf("\t%d",s1[i].total);
}
getch();
}
OUTPUT:
Enter the number of stuents2
Enter the roll number
4561
Enter the name
Lokesh
Enter the mark198
Enter the mark278
Enter the mark369
Enter the roll number
4562
Enter the name
Mani
Enter the mark188
Enter the mark289
Enter the mark398
The details of the mark list is as follows
Rollno Name Mark1 Mark2 Mark3 Total
4561 Lokesh 98 78 69 245
4562 Mani 88 89 98 275
RESULT:
ARRAY USING POINTERS
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,x[10];
int *ipa;
clrscr();
printf("Enter the number of elements:\n");
scanf("%d",&n);
printf("Enter the array numbers one by one\n");
for(i=0;i<n;i++)
scanf("%d",&x[i]);
printf("The elements present in the array are\n");
ipa=&x[0];
for(i=0;i<n;i++)
printf("\n%d",*(ipa+i));
getch();
}
OUTPUT:
Enter the number of elements:
4
Enter the array numbers one by one
8201
The elements present in the array are
8201
RESULT:
LINEAR SEARCH
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,n,key,f=0;
clrscr();
printf("\n\n LINEAR SEARCH \n\n");
printf("Enter the array limit:");
scanf("%d",&n);
printf("Enter array elements:\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the element to be searched:\n");
scanf("%d",&key);
for(i=0;i<n;i++)
{
if(a[i]==key)
{
printf("Element is found\n");
f=1;
break;
}
}
if(f==0)
{
printf("Element is not found\n");
}
getch();
}
OUTPUT:
LINEAR SEARCH
Enter the array limit:5
Enter array elements:
1
3
5
7
9
Enter the element to be searched: 9
Element is found
LINEAR SEARCH
Enter the array limit 5
Enter array elements:
2
4
6
8
10
Enter the element to be searched: 9
Element is not found
RESULT:
BINARY SEARCH
PROGRAM:
#include<stdio.h>
#include<conio.h>
int main()
{
int arr[50],i,n,x,flag=0,first,last,mid;
clrscr();
printf("Enter size of array:");
scanf("%d",&n);
printf("\nEnter array element(ascending order)\n");
for(i=0;i<n;++i)
scanf("%d",&arr[i]);
first=0;
last=n-1;
while(first<=last)
{
mid=(first+last)/2;
if(x==arr[mid]){
flag=1;
break;
}
else
if(x>arr[mid])
first=mid+1;
else
last=mid-1;
}
if(flag==1)
printf("\nElement is found at position %d",mid+1);
else
printf("\nElement is not found");
getch();
return 0;
}
OUTPUT:
RESULT:
BINARY SEARCH USING RECURSION
PROGRAM:
#include <stdio.h>
int binarySearch(int*, int, int, int, int);
int main()
{
int arr1[10], i, n, md, c, low, hg;
printf("\n\n Recursion : Binary searching :\n");
printf("-----------------------------------\n");
printf(" Input the number of elements to store in the array :");
scanf("%d", &n);
printf(" Input %d numbers of elements in the array in ascending order :\n", n); for (i = 0; i < n; i++)
{
printf(" element - %d : ", i);
scanf("%d", &arr1[i]);
}
printf(" Input the number to search : ");
scanf("%d", &md);
low = 0, hg = n - 1;
c = binarySearch(arr1, n, md, low, hg);
if (c == 0)
printf(" The search number not exists in the array.\n\n");
else
printf(" The search number found in the array.\n\n");
return 0;
}
int binarySearch(int arr1[], int n, int md, int low, int hg)
{
int mid, c = 0;
if (low <= hg)
{
mid = (low + hg) / 2;
if (md == arr1[mid])
{
c = 1;
}
else if (md < arr1[mid])
{
return binarySearch(arr1, n, md, low, mid - 1);
}
else
return binarySearch(arr1, n, md, mid + 1, hg);
}
else
return c;
}
OUTPUT:
element - 0 : 15
element - 1 : 25
element - 2 : 35
RESULT:
SELECTION SORT
PROGRAM:
#include <stdio.h>
int main()
{
int a[100], n, i, j, position, swap;
printf("Enter number of elementsn");
scanf("%d", &n);
printf("Enter %d Numbersn", n);
for (i = 0; i < n; i++)
scanf("%d", &a[i]);
for(i = 0; i < n - 1; i++)
{
position=i;
for(j = i + 1; j < n; j++)
{
if(a[position] > a[j])
position=j;
}
if(position != i)
{
swap=a[i];
a[i]=a[position];
a[position=swap;
}
}
printf("Sorted Array:n");
for(i = 0; i < n; i++)
printf("%dn", a[i]);
return 0;
}
OUTPUT:
RESULT:
READING A FILE
PROGRAM
#include<stdio.h>
void main( )
{
FILE *fp ;
char ch ;
fp = fopen("sample.txt","r") ;
while ( 1 )
{
ch = fgetc ( fp ) ;
if ( ch == EOF )
break ;
printf("%c",ch) ;
}
fclose (fp ) ;
}
OUTPUT:
Sample.txt
Department of CSE
RESULT:
EMPLOYEE INFORMATION
PROGRAM:
#include <stdio.h>
void main()
{
FILE *fptr;
int id;
char name[30];
float salary;
fptr = fopen("emp.txt", "w+");/* open for writing */
if (fptr == NULL)
{
printf("File does not exists \n");
return;
}
printf("Enter the id\n");
scanf("%d", &id);
fprintf(fptr, "Id= %d\n", id);
printf("Enter the name \n");
scanf("%s", name);
fprintf(fptr, "Name= %s\n", name);
printf("Enter the salary\n");
scanf("%f", &salary);
fprintf(fptr, "Salary= %.2f\n", salary);
fclose(fptr);
}
OUTPUT:
Enter e id 1
Enter the name
sonoo
Enter the salary
120000
emp.txt
Id= 1
Name= sonoo
Salary= 120000
RESULT:
FSEEK
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main(){
FILE *fp;
char c;
clrscr();
fp=fopen("myfile.txt","r");
while((c=fgetc(fp))!=EOF){
printf("%c",c);
}
fclose(fp);
getch();
}
OUTPUT:
Enter e id
myfile.txt
is sonoo jaiswal
RESULT:
FTELL
PROGRAM:
#include <stdio.h>
#include <conio.h>
void main ()
{
FILE *fp;
int length;
clrscr();
fp = fopen("file.txt", "r");
fseek(fp, 0, SEEK_END);
length = ftell(fp);
fclose(fp);
printf("Size of file: %d bytes", length);
getch();
}
OUTPUT:
Enter e id
1
Salary= 120000
RESULT:
REWIND
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
FILE *fp;
char c;
clrscr();
fp=fopen("file.txt","r");
while((c=fgetc(fp))!=EOF)
{
printf("%c",c);
}
rewind(fp);//moves the file pointer at beginning of the file
while((c=fgetc(fp))!=EOF){
printf("%c",c);
}
fclose(fp);
getch();
}
OUTPUT:
RESULT: