Posts

Showing posts with the label ACP

ACP Unit-4 Programs

ACP----Unit 4 Programs Note: 7 programs done..............! 1. Write a program to display contents of file on the screen. The program should ask for file name. Display the contents in capital case. ANS #include<stdio.h> #include<conio.h> void main() { FILE *fp; char letter,file_name[100]; clrscr(); printf("Enter file name(with extention) = "); gets(file_name); fp=fopen(file_name,"r"); if(fp == NULL) { printf("\nFile doesn't exits...!"); getch(); exit(0); } printf("\n"); while(!feof(fp)) { letter=getc(fp); if(letter>='a' && letter<='z') { printf("%c",letter-32); } else { printf("%c",letter); } } fclose(fp); getch(); } 2. Write a program to find size of the file. ANS #include<stdio.h> #include<conio.h> void main() { FILE *fp; ...

ACP Unit-2 Programs

ACP Unit 2 programs 1. Write a user defined function which will swap the values of two variables declared locally in the main program. ANS) #include<stdio.h> #include<conio.h> void swap(int *a,int *b); void main() { int n1,n2; clrscr(); printf("Enter value 1 = "); scanf("%d",&n1); printf("Enter value 2 = "); scanf("%d",&n2); printf("\nValues After swapping.........\n"); swap(&n1,&n2); printf("N1 = %d \nN2 = %d ",n1,n2); getch(); } void swap(int *a,int *b) { int tmp; //clrscr(); tmp=*b; *b=*a; *a=tmp; } 2. Write a user defined function calc(), which will returns the sum, subtraction, multiplication, and division values of two variable locally declared in the main function. ANS) #include<stdio.h> #include<conio.h> void calc(); void main() { int n1,n2,add,sub,mul,div; clrscr(); printf(...

ACP UNIT-1 programs + files

UNIT---1 1) Write a program to define structure with tag state with fields state name, number of districts and total population. Read and display the data.  ANS) #include<stdio.h> #include<conio.h> void main() { struct state { char nam[20]; long int  dis,pop; }state; clrscr(); printf("Enter Your state name = "); gets(state.nam); printf("Enter no of districts = "); scanf("%d",&state.dis); printf("Enter total population = "); scanf("%ld",&state.pop); printf("\n\nState name = %s",state.nam); printf("\n\nTotal District = %d",state.dis); printf("\n\nPopulation = %ld",state.pop); getch(); } 2) Write a program to create a list of books details. The details of a book include title, author, publisher, publishing year, number of pages, and price. ASN) #include<stdio.h> #include<conio.h>...

ACP--- (UNIT--3) Linked list program 1

Linked list program 1 (UNIT-3) #include<stdio.h> #include<conio.h> #include<alloc.h> void create(void); void display(void); void inserta(void); void insertb(void); void insertc(void); void deletea(void); void deleteb(void); void deletec(void); struct list { int no; struct list *next; }*start,*list,*temp; void main() { int ans=10; clrscr(); while(ans!=9) { clrscr(); printf("\nEnter choice = "); printf("\n1. Create "); printf("\n2. Display"); printf("\n3. Insert @ start"); printf("\n4. Insert @ between"); printf("\n5. Insert @ end"); printf("\n6. Delete @ start"); printf("\n7. Delete @ between"); printf("\n8. Delete @ end"); printf("\n9. Exit "); printf("enter your choice = "); flushall(); scanf("%d",&ans); switch(ans) { case 1: create(); break; case 2: display(); b...