Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
42 views
CS6212 / IT6212 - Programming and Data Structures Laboratory - I
CS6212 / IT6212 - Programming and Data Structures Laboratory - I
Uploaded by
bhuvangates
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save CS6212 / IT6212 - Programming and Data Structures ... For Later
Download
Save
Save CS6212 / IT6212 - Programming and Data Structures ... For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
42 views
CS6212 / IT6212 - Programming and Data Structures Laboratory - I
CS6212 / IT6212 - Programming and Data Structures Laboratory - I
Uploaded by
bhuvangates
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save CS6212 / IT6212 - Programming and Data Structures ... For Later
Carousel Previous
Carousel Next
Save
Save CS6212 / IT6212 - Programming and Data Structures ... For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 44
Search
Fullscreen
Rajalakshmi Engineering College Rajalakshmi Nagar, Thandalam, Chennai - 602 105 Department of Computer Science and Engineering CS6212 / IT6212 - Programming and Data Structures Laboratory - IC6212 / 176212 - PROGRAMMING AND DATA STRUCTURES LABORATORY - I BPG O30 Se Objectives: ‘The students should be made to: > Be familiar with e programming > Be exposed to implementing abstract data types > Lear to use files > Learn to implement sorting and searching algorithms. Experiments . C Programs using Conditional and Control Statements. 2. C Programs using Arrays, Strings and Pointers and Functions 3. Representation of records using Structures in © — Creation of Linked List ~ Manipulation of records in a Linked List. 4, File Handling in C ~ Sequemtial access ~ Random Access. 5. Operations on a Stack and Queue ~ infix to postfix — simple expression evaluation using stacks - Linked Stack Implementation — Linked Queue Implementation, Implementation of Sorting algorithms 7. Implementation of Linear search and Binary Search, TOTAL: 45 PERIODS Outcomes: At the end of the course, the student should be able to: v Design and implement C programs for implementing stacks, queues, linked lists v Apply good programming design methods for program development. > Apply the different data structures for implementing solutions to practical problems. v Develop searching and sorting programs, BHUVANESWARAN B/ AP (SS)/ CSE / REC - 2Write a program in C to find whether the given number is a perfect number or not. /* To find the given no. is perfect no. or not - CHKFERNO.C */ #include
#include
#include
void main() { int ip n, 8 = 0; elrser() ; printf["Enter a number : ") ; scanf("$d", &n) ; for(i = 1; i
#include
void maint) { inta=-1,b=1,c-0,i,n; elrserl) ¢ printf("Enter the limit : ") ¢ scanf("8d", @n) ¢ printf("\nThe fibonacci series is : \n\n") ; forli= 1; i <= nj itt) { cs atb: print£("$d \t", c) ¢ a=bi bec: getch() ; OUTPUT RUN 1 Enter the limit : 7 The fibonacci series is : BHUVANESWARAN B/ AP (SS)/ CSE/ REC - 4Write a program in C to find the factorial of a number using recursive functions. /* Pactorial of a given no. using recursive function - FACTREC.C */ #include
f#linclude
int factlint); void main() { int n, i, f= 1: clrser(}s printf ("Enter a number : ")i seanf("d", en); £ = factinis printf ("\nFactorial value of #d is : 8d", n, £) 3 geteh() + int fact{int n) { if(n ==0 || n return 1; else return(n * fact(n = 1))3 t ourpur RUN 1 Enter a number : 5 Factorial value of 5 is : 120 BHUVANESWARAN B/ AP (SS) / CSE/ REC -5Write a program in C to swap two integers number using pointers. /* Swap two numbers using pointers - SWAEPTR.C */ #include
#include
void swap{int *, int *); void main() t int x, y; elrser (1; printf("Enter the first no. : "li scanf("d", ax); printf ("Enter the sec scanf("8d", ay); printf ("\nBefore swap : swaplex, &y)? printf("\nAfter swap + getch()s ond no void swap(int *a, int *b} { int t7 t = 4a; *a = *b; te ourpur RUN 1 Enter the first no Enter the second no. : 20 Before swap : x = 10 After swap : x = BHUVANESWARAN B/ AP (SS) / CSE / REC - 6Write a program in C using dynamic memory allocation to print the transpose of a matrix. /*Transp of a matrix using dynamic memory allocation-MATTDMA. C*/ #include
#include
void main() { int **a; int row, col, i, 4¢ clrser(}s printf("Enter the order of the matrix : "); scanf("@d &d", grow, gcol); a= (int **) malloc(row * siz for(i = 0 7 i < col ; itt) { (int) ); ali] = (int *) malloc(cal * sizeof(int}]; printf("\nEnter the elements :\n"); forli = 0; i < row; i+) for(] = 0} 3 < col ; J++) scanf("sa", £4111): print£("\nThe transpose matrix is : \n\n"); for(j = 0; 4) < col ; j++) { forli { O07 i < rows itt) printé("$d \t", ali] [j])s printf("\n"); ourTPUT RUN 1 w Enter the order of the matrix : 2 Enter the elements : 1 2 3 4 5 6 The transpose matrix is wn BHUVANESWARAN B/ AP (SS) / CSE/ REC -7Write a function in C to add two matrices and print the resultant matrix. Write a main function to get the input and invoke the function. /* Add two matrices using functio: - MATADDEN.c */ #include
#include
void readmat(int [][10], int, int); void addmat(int [][10], int [][10], int [][10], int, int); void printmat(int [][10], int, int); void main() { int mata[10] [10], matb[10] [10], mate int row, col; elrser(}; printf["Enter the order of the matrix scant ("@d %d", grow, gcol); printf ("\nEnter the elements for first matrix : readmat (mata, row, col]; printf ("\nEnter the elements for readmat (matb, row, col]; print£["\nThe addition of matrix is : \n")s addmat (mata, matb, mate, row, col); printmat (mate, row, col); getch(}s [101; "ys void readmat{int mat[][10], int row, int col) int i, Ji for(i = 0; i < row; itt) for(j = 0: j < col ¢ j++} scanf("$a", smatlil (31) } void addmat (int mata[][10], int matb[][10], int matc[][10], int row, int col) { int i, 43 for(i = 07 i for(j = 0 3 < col ; j++} [i115] = matalil [3] + matblil (ils BHUVANESWARAN B/ AP (SS) / CSE/ REC -8void printmat (int mat[](10], int row, int col) { int 4, 4; for(i = 0 aH) printe("sd\t", mat(i] [ills print£("\n"); ourpur RUN 1 Enter the order of the matrix : 3 w Enter the elements for first matrix 1 3 5 7 9 a1 13 1s a7 Enter the elements for second matrix : 2 4 6 8 10 ue 14 16 18 The addition of matrix is : 3 7 1 15 19 23 27 31 35 BHUVANESWARAN B/ AP (SS) / CSE/ REC - 9Write different functions in C that will compute and print the area of any four geometric shapes. Write a main function to get the input and invoke the function using switch case conditional statement. /* Program to compute areas of geometric shapes - AREAS.C */ f#include
#include
void main() { int choice; float side, base, length, breadth, height, area, radius; print£("1. Circle\n"); printfi"2. Rectangle\ printf("3. Triangle\n" printf("4. square\n"]; print£("Enter your choice : "Iz scanf("$d", &choice); ch (choice) { el: printf("Enter the radius +"); can£("$£", gradius}; area = 3.142 * radius * radius; printf ("Area of a circle = &f", area); break; case 2: printf("Enter the breadth and length : " scanf("$f %£", sbreadth, slength); area = breadth * length; printf("Area of a Reactangle = $f", areal; break; case 3: print£("Enter the base and height : scanf("8f #f", sbase, gheight]; area = 0.5 * base * height; printf("Area of a Triangle = %£", area); break; case 4: printf ("Enter the side : "J; scanf("8f", &side); area - side * side; printf ("Area of a Square = #f\n", area); break; default: printf ("Invalid choice...1")¢ break; getch(}+ BHUVANESWARAN B/ AP (SS) / CSE / REC - 10ourpur RUN 1 1. Circle 2. Rectangle 3. Triangle 4. Square Enter your choice : 1 Enter the radius : 5 Area of a circle = 78.550003 RUN 2 1. Circle 2. Rectangle 3. Triangle 4, Square Enter your choice : 2 Enter the breadth and length : 3 4 Area of a Reactangle = 12.000000 RUN 3 1. Circle 2. Rectangle 3. Triangle 4. Square Enter your choice : 3 ns Enter the base and Area of a Triangle height RUN 4 Circle Rectangle Triangle Square Enter your choice Enter the side : 5 Area of a Squa 5.000000 BHUVANESWARAN B/ AP (SS) / CSE / REC - 11Write a program in C to find whether a substring is present in the string or not. /* Pind whether a substring is present in the string - SUBSTR.C #include
#include
#include
void main() { char str[60], search[10] int countl = clrser()s printfi"Enter the string gets(str}z printf("Enter search substring : "} gets{search); countl = strlen(str); count2 strlen(search]; for (i = 0; i countl - count2; i++) { for (j = is 3
onio.h> ‘type #include < include < #include < h> void main() { char text[80], ch ; int vowels = 0, cons = 0, digits = 0, spaces = 0, clrser() + printf ("Enter the text :") ¢ gets(text) > while{{ch = tolower(text litt] }] Nor) { if(ch=="a' || ttyowels ; else if(ch +tcons else if(ch t+digits ; else if(ch t+spaces ; printf["\nThe text contains : ") ; print£("\n\nNumber of vowels = $4", vowels) ; print£("\n\nNumber of consonants = 8d", cons) ; printf ("\n\nNumber of digits = $d", digits) ; print£("\n\nNumber of white spaces = $d", spaces) geten() ¢ ourpur RUN 1 Enter the text : Kancheepuram Pincode 631501 The text contains : Number of vowels = 8 Number of consonants = 11 Number of digits Number of white spaces - BHUVANESWARAN B/ AP (SS) / CSE / REC - 14 OFWrite a program in C to implement the concept of Sequential Access in files. /* Program to write and read data from a file - FILEWRRD.C */ tdio.h> onio.h> #include < include < void main() t FILE *fptr ; char c ; elrser() ¢ printf("Enter the text to be stored in the file.\n") + printf("Use *Z or F6 at the end of the text and press ENTER: \n\n") > fptr = fopen( "COURSES. DAT", "w while(({c = getchar(}} != EOF) pute(c, fptr) ; fclose(fptr) + printf("\nThe content of the file is : \n\n") ; fptr = fopen("COURSES.DAT™, "r") ; while({c = getc{fptr)) != EOF} printf("so", c) ; felose(fptr) ¢ getch() ; OUTPUT RUN 1 Enter the text to be stored in the file. Use *“Z or F6 at the end of the text and press ENTER: Computer Science & Engineering Information Technology Electronics & Communication Engineering The content of the file is : Computer Science & Engineering Information Technology Electronics & Communication Engineering BHUVANESWARAN B/ AP (SS) / CSE / REC - 15Write a program in C to implement the concept of Random Access in files. (or) Write a C program to perform random access on file. /* Implementation of random access files - RANDOM.C */ #include
#include < onio.h> void main{) { FILE *fptrs long nj char o elrser(1; fptr = fopen("ALPHABET.DAT", "w"); printf ("Enter the alphabets (*Z to end) : \n"I; while(({c = getchar()} != EOF) putc(c, fptris printf("No. of characters entered = $1d\n", ftell(fptr))s felose(fptr)s fptrc = fopen("ALPHABET.DAT", "x")¢ n= 01; while(feof(fptr) == 0} { fseek(fptr, n, 015 printf("Position of 8c is #1d\n", gete(fptr}, ftell(fptr)); nen + Sl; putchar('\n"); fseek(fptr, -1L, 2); do { putchar(gete(fptr]}; } while(!fseek(fptr, -2L, 1))i felose(fptr) + geten() ; t ourPUT RUN 1 Enter the alphabets (°Z to end) : ABCDEFGHIJKLMNOPQRSTUVWKYZ°Z No. of characters entered = 26 Position of A is Position of F is Position of Position of Position of U is Position of Z is Position of is is is NouaAnS web SRSES ZYXWVUTSROPONMLI a a a 5 a o 3 a 3 BHUVANESWARAN B/ AP (SS) / CSE / REC - 16Write a C program to find sum of digit, reversal of digit and largest of digit. /* Pind the sum, reverse and largest of digits - SUMREVLA.C */ tdio.h> onio.h> #include < include < void maint) { int n, rem, large elrserl) ¢ printf ("Enter a number :") ¢ scanf("8d", @n) ¢ while{n > 0} { n& 103 sum + rem ¢ = rem + rev * 10; n=n/10¢ if(rem > large) large = rem; printfi"\nThe sum of the digits is : ad", sum) ; printf ("\nThe reverse of the digit is : 8d", r printf("\nThe largest of the digit is : %a", largel: geten() ¢ t ourpur RUN 1 Enter a number : 786 The sum of the digits is : 21 The reverse of the digit is : 687 The largest of the digit is : 8 BHUVANESWARAN B/ AP (SS) / CSE / REC - 17Write a C program to generate the Armstrong numbers from 1 - 1000. /* Program to generate armstrong numbers - GENARMST.C */ #include
#include
void main{) { int i, a, ry si clrser() ¢ print£("\nThe armstrong numbers from 1 to 1000 are z\n\n") ¢ for{i = 0 7 i <= 1000; i++) { a-i; a- 0; while(a > 0} t xr ; 5 eee che a ; if(i == s) printf("sd\t", i) ¢ getch() ; RUN 1 The armstrong numbers from 1 to 1000 are : a 1 153 370 371 407 BHUVANESWARAN B/ AP (SS) / CSE / REC - 18Write a C program to find the product of two matrices using Array. (or) Develop a ‘Cc’ program for matrix multiplication. /* Program to multiply the given two matrices - MATMUL.C */ #include
f#linclude
void maint) t int mata[10] [10], matb[10] [10], matc[10] [10] + int i, J, ky rowl, coll, row2, col2 i elrser() ; printf("Enter the order of first matrix i") 3 scanf("8d td", growl, &coll) ; printf("\nEnter the order of second matrix : " scant ("ad $d", @row2, &col2) ; if(coll == row2) { printf("\nEnter the elements of first matrix : \n\n") + for(i = 0 7 i < rowl ; i++) for(j = 0; 3 < coll ; j+t] scanf("8d", &matalil[i]} printf("\nEnter the elements of s for(i = 0; 1 < row2 ; i++) nd matrix : \n\n") ¢ for(j = 0% 4 < col2 ; j++) scanf("#d", amatb[1i][j]} ¢ for{i = 0; 1 < rowl 3 I++) i col2 ; j++] mate(i](4] = 03 for{k = 0; k < coll ; k++) mate(il(] = matelil[j] + mata[i][k] * matb[k][j] ¢ } printf("\nThe resultant matrix is : \n\n") ; for(i = 07 i < rowl ; i++) t for({] = 0; } < col2 7 +4] { printf("’d \t", matelil(3]) ¢ print£("\n") ¢ t else printf ("\nMatrix Multiplication is not possible ...") 7 getch{) ; BHUVANESWARAN B/ AP (SS) / CSE / REC - 19ourpur RUN 1 Enter the Enter the Enter the 1 1 1 1 1 1 Enter the 1 1 1 1 1 1 order of first matrix order of second matrix: 3 3 elements of first matrix : elements of second matrix : The resultant matrix is : 3a 3 3 3 3 3 RUN 2 Enter the Enter the wow order of first matrix :3 3 order of second matrix Matrix Multiplication is not possible ... BHUVANESWARAN B/ AP (SS) / CSE / REC - 20Write a C program to perform addition, subtraction and multiplication of two numbers using pointers and functions. /* Arithmetic operations using pointers and functions-AOPTREN.C */ #include
#include < onio.h> int add{int *, int *); int sub(int *, int *); int mul(int *, int *); void main{) { int first, second, sum, diff, pro elrser(); printf ("Enter the first number : "); scanf("8d", &first); printf ("Enter the se scanf("8d", &second); sum = add(éfirst, &second); diff = sub(sfirst, ssecond); prod = mil (sfirst, &second); printf£("\ntd + 8d = first, second, sum); printf("\nsd - ad » first, second, diff); printf("\ntd + &d first, second, prod); getch()+ ond number : ")j int add(int *x, int *y} { return *x + * int sub(int *x, int *y) { return *x - *y: F int mul{int *x, int *y) t return *x * *y; ourpur RUN 1 Enter the first number : 10 Enter the second number : 5 BHUVANESWARAN B/ AP (SS) / CSE / REC - 21Write a C program to perform file copy and append operation on a file. /* Program to perform file copy and append - COPYAPP.C */ #include
#include
void maint) t char c 3 FILE *fptri, *fptr2 ; elrser() + printf ("Enter the text - FIRST.DAT : \n") printf ("Press *Z or F6 at the end of the text\n"); fptrl = fopen("FIRST. DAT", "w"} while({c = getchar(}} != EOF) putc(c, fptrl) ; felose(fptr1) ¢ fptrl = fopen{"FIRST.DAT","r") + fptr2 = fopen("SECOND.DAT","w") 7 while({e = gete(fptr1)] != EOF) pute(c, fptr2) ; felose(fptrl) : felose(fptr2) ; print£("Content of file - SECOND.DAT : \n"); fptr2 = fopen{"SECOND.DAT","«") 7 while({c = getc(fptr2)) != EOF) printf("se", ¢) ; felose(fptr2) ; printf ("Enter the text to append : \n") ; printf ("Press “Z or F6 at the end of the text\n"); fptrl = fopen("FIRST.DAT","a") ¢ while({c = getchar()) != EOF) pute(c, fptr1) ; felose(fptrl] ; printf ("Content of file - fIRST.DAT : \n"); fptrl = fopen{"FIRST.DAT","r")} + while({c = getc(fptr1)] t= EOF} print£("$o", c} felose(fptrl) ¢ getch{) ; t BHUVANESWARAN B/ AP (SS) / CSE / REC - 22ourpur RUN 1 Enter the text - FIRST.DAT : Press “Z or F6 at the end of the text Rajalakshmi Engineering College Thandalam Content of file - SECOND.DAT : Rajalakshmi Engineering College Thandalam Enter the text to append : Press “Z or F6 at the end of the text Chennai - 602 105 Content of file - FIRST.DAT : Rajalakehmi Engineering College Thandalam Chennai - 602 105 BHUVANESWARAN B/ AP (SS) / CSE / REC - 23Develop a ‘C’ program to implement a simple calculator using switch case statement. /* Performing arithmetic operations using switch...case-ARITH.C */ #include
#include
void main() { int nl, n2, ch; elrser() + printf ("Enter the first number : ") scanf("8d", anl) ; printfi"\nEnter the second number : ") ; seanf("8d", en2) printf£("\n[1] -> Addition ") printf("\n[2] -> Subtraction ") ; printf ("\n[3] -> Multiplication ") ; printf£("\n[4] -> Division ") printf("\n\nEnter your choice <1...4> 2"); scant ("@d", ) switch {ch} { case 1: printf("\nd + $d = 8a", nl, n2, nl + n2 break ; case 2: printf("\nd - $d = 8d", nl, n2, nl - n2) break ; 3: print£("\ntd * $d = da", nl, n2, nl * break ; case 4: printf("\ntd / #d = 8.21", nl, (float)yn1 / n2) break ; default printf["\nInvalid choice"); break ¢ geteh(): BHUVANESWARAN B/ AP (SS) / CSE / REC - 24ourpur Enter the first number Enter the second number : 5 Addition [2] -> Subtraction (31 Multiplication [4] -> Division (1) Enter your choice
10 * 5 = 50 BHUVANESWARAN B/ AP (SS) / CSE / REC - 25Develop a ‘Cc’ program to find the greatest of ‘N’ numbers stored in an array. /* Greatest of n numbers stored in an array - ARRGREAT. #include
#include
void maint) { int a[10], n, i, g3 elrser(); printf ("Enter the number of elements : scanf("8d",an)z print£("\nEnter the elements for(i = 07 i < nz i++) scanf("8d", galills g = al0]; forfi - 14 4 née if(alil > 9) g = ali); att) print£("\nThe greatest number is getch(}7 ourPpur RUN 1 Enter the number of elements : 5 Enter the elements : 20 The greatest number is : 30 50 40 50 "8 An"): BHUVANESWARAN B/ AP (SS) / CSE / REC - 26Develop a ‘C’ program to print the number of vowels in a given paragraph. /* Number of vowels in a given paragraph - VOWELS #include
include
#include
void main() { char text[80], chy int vowels=0, i; elrser (lz *f printf ("Enter the paragraph : \n"}; gets(text) ¢ forli = 0% textfil "Nol; itt) print ("Numb qetch(); ourPpUT RUN 1 Enter the paragraph Anna University, Chennai Number of vowels = 9 8a", vowels); BHUVANESWARAN B/ AP (SS) / CSE / REC - 27Develop a ‘C’ program to find the transpose of a given matrix. /* Program to transpose the given matrix - MATTRANS.C */ #include
#include
void main() { int mat [10] [10] ¢ int i, j, row, col ; elrserl) ¢ printf ("Enter the order of the matrix : ") scanf("ad 8d", grow, &col) 7 printf("\nEnter the elements of the matrix : \n\n") ; for(i = 0; i < row; itt) for(j = 0 7 3 < col + j++} anf("$d", emat [i] (j]) printf ("\nThe transpose matrix is for(j = 07 3 < col + j++ \n\n") ¢ forli = 0; i < row; itt) printf("$d \t", mat(i](j]) + printf£("\n") geten() ¢ t ourpur RUN 1 Enter the order of the matrix Enter the elements of the matrix : 2 4 5 ow The transpose matrix is : BHUVANESWARAN B/ AP (SS) / CSE / REC - 28Develop a ‘C’ program to add two matrices. /* Program to add the given two matrices - MATADD.C */ #include
#include
void main() { int mata[10] [10], matb[10] [10], mate[10] [10] + int i, j, row, elrserl) ¢ printf ("Enter the order of the matrix : ") ; scanf("ad 8d", grow, &col) 7 printfi"\nEnter the elements of first matrix : \n\n") + for(i = 0; i < row; itt) for(j = 0 7 3 < col + j++} nf ("sd", gmatalil[j]) + print£("\nEnter the elements of second matrix : \n\n") + forli = 0; i < row; itt) for(j = 0%} < col j++) scanf("8d", ématbli][j]) + 7 i < row; itt) 0% 4 < cols J++) mate[i][4] = matali] [J] + matb[il(3] + print£("\nThe resultant matrix is : \n\n") forli for(j or(L = 07 1 < row ; itt) : for(j = 07 4 < cols i+) ' printf("$d \t", mateli](i]) ¢ printe("\n") 3 getch() BHUVANESWARAN B/ AP (SS) / CSE / REC - 29ourpur RUN 1 Enter the order of the matrix : 3 w Enter the elements of first matrix : 1 5 a7 Bae Enter the elements of s 2 4 6 8 10 12 14 16 18 The resultant matrix is : 3 1 15 19 23 27 31 35 BHUVANESWARAN B/ AP (SS) / CSE / REC - 30Define a structure called cricket that will describe the following information: Player Code Player Name Team Name Batting Average Using cricket, declare an array player with ‘N’ elements and develop a ‘C’ program to read the information about all the ‘N’ players and print a team wise list containing names of players with their batting average. /* Cricket using structure ~ CRI 2 / include
#include
struct cricket { char peode[10]z char pname[20]; char tname[20]z int avgs } player[50], temp; void main() { int i, 4, clrser(}; printf ("Enter number of players : "1; scanf("$d", en); for(i = 0; 1 < nz i++) { printf("\nEnter player code : " scanf("ss", player[1] .peode); printf ("Enter player name : "); scanf("ss", player[1].pname); printf("Enter team name : ")i scanf("$s", player[i].tname); printf("Enter batting average : "); scanf("$a", gplayer[i].avg)i for(i = 1; i < nj it) for(j = 07 j
0) { temp = player[i]+ player[j] = player[j + ll; player[j + 1] = temp; BHUVANESWARAN B/ AP (SS) / CSE / REC - 31printf ("\nTeam \t Player \t Average\n"); for(i = 0; 4
#include
void main{) { int i, J, n, count = 0; clrser() 3 printf("Enter the no. of elements : ") + seanf("8d", en) ¢ printf£("\nThe prime numbers are :\n\n") + for (i = 1% count
#include
void main{) { char str[20], rev[20]; int i, j, length = 0, flag = 0; elrser(}; printf ("Enter a string : ")3 scanf("8s", str): for(i = 0; str[il NOE itt) length++; for(i = length - 1; i > iss) rev[length - i - 1] = str[il fori = 0; i < length; i++) { if(str[i] t= rev[i]) { flag = 1; break; t if(flag == 0) printf("\nThe given string is a palindrome") ; else printf£("\nThe given string is not a palindrome") ; getch() ; ourPUT RUN 1 Enter a string : madam The given string is a palindrome RUN 2 Enter a string : malayalam The git n string is a palindrome RUN Enter a string : bhuvan The given string is not a palindrome BHUVANESWARAN B/ AP (SS) / CSE / REC - 34Develop a ‘C’ program to reverse a given string. /* Program to reverse the given string - STRREV.C */ #include
#include
void main() { char str(20], rev[20] + int i, j, li elrserl) ¢ printf ("Enter a string : ") ¢ scanf("8s", str) ; for(1 = 0; str[1l forli- 1-1, 4-0 rev[j] = str[il rev[j] = '\0"; printf ("\nThe given string is : @s\n\n", str) ; printf ("The reversed string is : $s", rev) ; geteh() ; "Nor p 1+4) i >= 03 in-, i++) ourpuT RUN 1 Enter a string : bhuvan The given string is : bhuvan The reversed string is : navuhb BHUVANESWARAN B/ AP (SS) / CSE / REC - 35Develop a ‘Cc’ function that will scan a character string passed as an argument and convert all lower-case characters to their upper- case equivalents. /* Lower case to upper case using function ~ LCUCEUNC.C +*/ flinclude
void upper(char[]}s void main() { str [20]; Og printfi"Enter the string seanf("%s", str}s printf("The upper case equivalent is : "Is upper (str); getch(s M void upper(char str{] int if for(i = 0 ; str[i] ; i++) if(str[i] > 96 @& str[i] < 123) str[i] = str[i] - 32; puts(str}; ourpur RUN 1 Enter the string : University The upper case equivalent is : UNIVERSITY BHUVANESWARAN B/ AP (SS) / CSE / REC - 36Develop a ‘C’ program to sort ‘N’ names alphabetically. /* To sort the given strings in alphabetical order - STRSORT.C */ #include
#include
f#include
void maint) t char atr[10] [20], temp[20] + int n, i, ji elrser() ; printf£("Enter the number scanf("8d", an) ; printf ("\nEnter the strings : \n\n") ¢ for(i = 0; i
0) { f strings : ") ¢ strepy(temp, str[jl} + strepy(stc[}], str[j + 1]) 7 strepy(str[} + 1], temp) ; printf("\nThe sorted order of strings are : \n\n™) ; for(i = 0; 1
#include
void main{) { int n, i, count = clrser(\i printf ("Enter the no. of elements : "}; scanf("8d", 6); print£("\nThe numbers divisible by 5 are :\n\n"); for(i = 1; count
f#linclude
long fact(int n}; void main{) [ long n, res ; elrsert) + printf ("Enter a number : ") ¢ scanf("@ld", &n) ¢ res = fact(n) ¢ printf ("\nFactorial value of $ld is : $1ld", n, res) geteh() + fact (int nj long i, f= 13 for(i = 1; i <=n; itt) fo 6" 4 return f; ourpur RUN 1: Enter a number Factorial value of 5 is : 120 BHUVANESWARAN B/ AP (SS) / CSE / REC - 39Develop a ‘C’ program that will create a data file containing the list of telephone numbers in the following table: Name Telephone No John 23456 Peter 9876 Use sequential access file. Perform search operation. /* Sequential file acc s and search op #include
#include
void main() { FILE *fptr ; inti, nz char name[10] ¢ long phoneno, search; elrser{} + fptr = fopen("TELDIR.DAT", "w") 7 printf("Enter the number of persons : ") ; scanf("’d", an) ; forfi= 1; i
#include
void maint) { intn, r, 8-07 elrserl) ¢ printf ("Enter a number :") ¢ scanf("8d", @n) ¢ while{n > 0} { a + n=n/ printf("\nThe sum of the digits is : 8d", 5) ; getch(} ¢ OUTPUT RUN 1 Enter a number : 12345 The sum of the digits is : 15 BHUVANESWARAN B/ AP (SS) / CSE / REC - 44
You might also like
CS8391-Data Structures-Anna University Question Papers
PDF
80% (5)
CS8391-Data Structures-Anna University Question Papers
8 pages
C-Lab-manual
PDF
No ratings yet
C-Lab-manual
16 pages
C Lab Manual
PDF
No ratings yet
C Lab Manual
16 pages
BCA Lab Project
PDF
No ratings yet
BCA Lab Project
18 pages
Write an algorithm to convert a decimal number to its equivalent hexadecimal number
PDF
No ratings yet
Write an algorithm to convert a decimal number to its equivalent hexadecimal number
13 pages
Fundamentals of Data Structures Lab Manual
PDF
No ratings yet
Fundamentals of Data Structures Lab Manual
52 pages
C Program lab Manual
PDF
No ratings yet
C Program lab Manual
24 pages
Cprogram Final Lab Manual
PDF
No ratings yet
Cprogram Final Lab Manual
26 pages
C Programming Lab Manual
PDF
No ratings yet
C Programming Lab Manual
26 pages
32-50 Programs
PDF
No ratings yet
32-50 Programs
24 pages
DS Lab MANUAL
PDF
No ratings yet
DS Lab MANUAL
51 pages
Source Code Final
PDF
No ratings yet
Source Code Final
27 pages
Assignment # 4: NAME:Bilal Mehdi Roll No: SP20-BSE-019
PDF
No ratings yet
Assignment # 4: NAME:Bilal Mehdi Roll No: SP20-BSE-019
13 pages
Course Code: MCS-011 Course Title: Problem Solving and Programming
PDF
No ratings yet
Course Code: MCS-011 Course Title: Problem Solving and Programming
9 pages
Advance C (Problem Sheet)
PDF
No ratings yet
Advance C (Problem Sheet)
28 pages
C Programming Lab Manual
PDF
No ratings yet
C Programming Lab Manual
27 pages
c Slip Answers 21-30
PDF
No ratings yet
c Slip Answers 21-30
5 pages
DOC-20241208-WA0009.
PDF
No ratings yet
DOC-20241208-WA0009.
9 pages
Lab Report
PDF
No ratings yet
Lab Report
8 pages
PST Programs
PDF
No ratings yet
PST Programs
14 pages
PC Lab Manual
PDF
No ratings yet
PC Lab Manual
23 pages
shreyas 096 c lab
PDF
No ratings yet
shreyas 096 c lab
24 pages
C Programming
PDF
No ratings yet
C Programming
9 pages
Ajay Kumar Garg Engineering College: 27 KM Stone Delhi-Hapur Bypass Road, P.O. Adhyatmik Nagar Ghaziabad-201009
PDF
No ratings yet
Ajay Kumar Garg Engineering College: 27 KM Stone Delhi-Hapur Bypass Road, P.O. Adhyatmik Nagar Ghaziabad-201009
51 pages
ESC135_SESSION-1_to_10 (1)
PDF
No ratings yet
ESC135_SESSION-1_to_10 (1)
32 pages
PPS LAB MANUAL II SEM
PDF
No ratings yet
PPS LAB MANUAL II SEM
46 pages
C Program List
PDF
No ratings yet
C Program List
22 pages
Basic Programs C Language
PDF
No ratings yet
Basic Programs C Language
42 pages
270E150
PDF
No ratings yet
270E150
32 pages
priyanka c program 11
PDF
No ratings yet
priyanka c program 11
25 pages
The Sum and Average of N Number of Marks of A Student
PDF
No ratings yet
The Sum and Average of N Number of Marks of A Student
28 pages
C
PDF
No ratings yet
C
14 pages
List of Small Programmes
PDF
No ratings yet
List of Small Programmes
17 pages
EC CODING new_merged
PDF
No ratings yet
EC CODING new_merged
66 pages
AAYUSH MALVIYA REPORT ON C
PDF
No ratings yet
AAYUSH MALVIYA REPORT ON C
46 pages
RECORD.pdf
PDF
No ratings yet
RECORD.pdf
74 pages
C Program Rcu
PDF
100% (1)
C Program Rcu
52 pages
C Programs: Program To Demostrate Arithmetic Operators
PDF
No ratings yet
C Programs: Program To Demostrate Arithmetic Operators
56 pages
CP lab manual
PDF
No ratings yet
CP lab manual
20 pages
two-Dimensional Arays in C
PDF
No ratings yet
two-Dimensional Arays in C
4 pages
Ce unit-4
PDF
No ratings yet
Ce unit-4
13 pages
Board Question C Program Solve
PDF
No ratings yet
Board Question C Program Solve
33 pages
c pro word[1
PDF
No ratings yet
c pro word[1
31 pages
C Program 60
PDF
No ratings yet
C Program 60
17 pages
LAB PROGRAMS
PDF
No ratings yet
LAB PROGRAMS
17 pages
BSCS CC-112 PF 2022 Solved
PDF
No ratings yet
BSCS CC-112 PF 2022 Solved
8 pages
MCA_PPS_LAB_MANAUL
PDF
No ratings yet
MCA_PPS_LAB_MANAUL
32 pages
C Program 60 (Aditya Ingale)
PDF
No ratings yet
C Program 60 (Aditya Ingale)
95 pages
25 Programs of C-1
PDF
No ratings yet
25 Programs of C-1
31 pages
C Programming I - Karl W Broman
PDF
No ratings yet
C Programming I - Karl W Broman
22 pages
Quant Masters
PDF
No ratings yet
Quant Masters
220 pages
c Manual
PDF
No ratings yet
c Manual
31 pages
C Programs
PDF
No ratings yet
C Programs
16 pages
Bba Solution
PDF
No ratings yet
Bba Solution
15 pages
PPS Practical Solution
PDF
No ratings yet
PPS Practical Solution
14 pages
The Lecture For Turbo C
PDF
100% (5)
The Lecture For Turbo C
82 pages
The Lecture For Turbo C
PDF
No ratings yet
The Lecture For Turbo C
82 pages
Simple Statemens and Expressions-Data Types
PDF
No ratings yet
Simple Statemens and Expressions-Data Types
32 pages
BCS3L1-Data Structure lab
PDF
No ratings yet
BCS3L1-Data Structure lab
41 pages
CB19511 IPL Syllabus
PDF
No ratings yet
CB19511 IPL Syllabus
1 page
B.Bhuvaneswaran, AP (SG) / CSE, REC: 13 January 2022
PDF
No ratings yet
B.Bhuvaneswaran, AP (SG) / CSE, REC: 13 January 2022
12 pages
Cloudsim Toolkit - Course Contents
PDF
No ratings yet
Cloudsim Toolkit - Course Contents
1 page
Cloud Sim Manual
PDF
No ratings yet
Cloud Sim Manual
40 pages
CB19742 IT Workshop (Scilab Matlab)
PDF
No ratings yet
CB19742 IT Workshop (Scilab Matlab)
2 pages
CB19442 DT
PDF
0% (1)
CB19442 DT
1 page
CPP 05 PDF
PDF
50% (2)
CPP 05 PDF
1 page
MWA Syllabus
PDF
No ratings yet
MWA Syllabus
1 page
CB19541 AAD Syllabus
PDF
No ratings yet
CB19541 AAD Syllabus
2 pages
CPP 01 PDF
PDF
No ratings yet
CPP 01 PDF
1 page
CS19611 MADL Syllabus
PDF
No ratings yet
CS19611 MADL Syllabus
2 pages
CPP 02 PDF
PDF
0% (1)
CPP 02 PDF
1 page
IT6601 MC AU QP Reg 2013
PDF
No ratings yet
IT6601 MC AU QP Reg 2013
11 pages
CPP 03 PDF
PDF
No ratings yet
CPP 03 PDF
1 page
CPP 04 PDF
PDF
No ratings yet
CPP 04 PDF
1 page
CB19241-Data Structures and Algorithms-Syllabus
PDF
No ratings yet
CB19241-Data Structures and Algorithms-Syllabus
1 page
C MCQ
PDF
0% (1)
C MCQ
42 pages
Stack ADT
PDF
No ratings yet
Stack ADT
36 pages
CB19241-CSBS-Data Structures and Algorithms-Lab Syllabus
PDF
No ratings yet
CB19241-CSBS-Data Structures and Algorithms-Lab Syllabus
3 pages
CB19241-CSBS-Data Structure and Algorithms-Theory-Syllabus
PDF
No ratings yet
CB19241-CSBS-Data Structure and Algorithms-Theory-Syllabus
4 pages
Anna University - Dec - 2018 - Time Table
PDF
No ratings yet
Anna University - Dec - 2018 - Time Table
57 pages
OOPs Class Test - Answers
PDF
No ratings yet
OOPs Class Test - Answers
10 pages
Problem Solving and Python Programming Assignment - III
PDF
No ratings yet
Problem Solving and Python Programming Assignment - III
8 pages
CSS Important MCQ Questions
PDF
100% (2)
CSS Important MCQ Questions
16 pages
C Basics Crossword Puzzle
PDF
No ratings yet
C Basics Crossword Puzzle
2 pages
Thingspeak IoT
PDF
No ratings yet
Thingspeak IoT
7 pages
01 Python Introduction
PDF
No ratings yet
01 Python Introduction
13 pages
CS6202 - PDS - I - Unit Test - I - Important Questions - Part - A
PDF
No ratings yet
CS6202 - PDS - I - Unit Test - I - Important Questions - Part - A
8 pages
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
CS8391-Data Structures-Anna University Question Papers
PDF
CS8391-Data Structures-Anna University Question Papers
C-Lab-manual
PDF
C-Lab-manual
C Lab Manual
PDF
C Lab Manual
BCA Lab Project
PDF
BCA Lab Project
Write an algorithm to convert a decimal number to its equivalent hexadecimal number
PDF
Write an algorithm to convert a decimal number to its equivalent hexadecimal number
Fundamentals of Data Structures Lab Manual
PDF
Fundamentals of Data Structures Lab Manual
C Program lab Manual
PDF
C Program lab Manual
Cprogram Final Lab Manual
PDF
Cprogram Final Lab Manual
C Programming Lab Manual
PDF
C Programming Lab Manual
32-50 Programs
PDF
32-50 Programs
DS Lab MANUAL
PDF
DS Lab MANUAL
Source Code Final
PDF
Source Code Final
Assignment # 4: NAME:Bilal Mehdi Roll No: SP20-BSE-019
PDF
Assignment # 4: NAME:Bilal Mehdi Roll No: SP20-BSE-019
Course Code: MCS-011 Course Title: Problem Solving and Programming
PDF
Course Code: MCS-011 Course Title: Problem Solving and Programming
Advance C (Problem Sheet)
PDF
Advance C (Problem Sheet)
C Programming Lab Manual
PDF
C Programming Lab Manual
c Slip Answers 21-30
PDF
c Slip Answers 21-30
DOC-20241208-WA0009.
PDF
DOC-20241208-WA0009.
Lab Report
PDF
Lab Report
PST Programs
PDF
PST Programs
PC Lab Manual
PDF
PC Lab Manual
shreyas 096 c lab
PDF
shreyas 096 c lab
C Programming
PDF
C Programming
Ajay Kumar Garg Engineering College: 27 KM Stone Delhi-Hapur Bypass Road, P.O. Adhyatmik Nagar Ghaziabad-201009
PDF
Ajay Kumar Garg Engineering College: 27 KM Stone Delhi-Hapur Bypass Road, P.O. Adhyatmik Nagar Ghaziabad-201009
ESC135_SESSION-1_to_10 (1)
PDF
ESC135_SESSION-1_to_10 (1)
PPS LAB MANUAL II SEM
PDF
PPS LAB MANUAL II SEM
C Program List
PDF
C Program List
Basic Programs C Language
PDF
Basic Programs C Language
270E150
PDF
270E150
priyanka c program 11
PDF
priyanka c program 11
The Sum and Average of N Number of Marks of A Student
PDF
The Sum and Average of N Number of Marks of A Student
C
PDF
C
List of Small Programmes
PDF
List of Small Programmes
EC CODING new_merged
PDF
EC CODING new_merged
AAYUSH MALVIYA REPORT ON C
PDF
AAYUSH MALVIYA REPORT ON C
RECORD.pdf
PDF
RECORD.pdf
C Program Rcu
PDF
C Program Rcu
C Programs: Program To Demostrate Arithmetic Operators
PDF
C Programs: Program To Demostrate Arithmetic Operators
CP lab manual
PDF
CP lab manual
two-Dimensional Arays in C
PDF
two-Dimensional Arays in C
Ce unit-4
PDF
Ce unit-4
Board Question C Program Solve
PDF
Board Question C Program Solve
c pro word[1
PDF
c pro word[1
C Program 60
PDF
C Program 60
LAB PROGRAMS
PDF
LAB PROGRAMS
BSCS CC-112 PF 2022 Solved
PDF
BSCS CC-112 PF 2022 Solved
MCA_PPS_LAB_MANAUL
PDF
MCA_PPS_LAB_MANAUL
C Program 60 (Aditya Ingale)
PDF
C Program 60 (Aditya Ingale)
25 Programs of C-1
PDF
25 Programs of C-1
C Programming I - Karl W Broman
PDF
C Programming I - Karl W Broman
Quant Masters
PDF
Quant Masters
c Manual
PDF
c Manual
C Programs
PDF
C Programs
Bba Solution
PDF
Bba Solution
PPS Practical Solution
PDF
PPS Practical Solution
The Lecture For Turbo C
PDF
The Lecture For Turbo C
The Lecture For Turbo C
PDF
The Lecture For Turbo C
Simple Statemens and Expressions-Data Types
PDF
Simple Statemens and Expressions-Data Types
BCS3L1-Data Structure lab
PDF
BCS3L1-Data Structure lab
CB19511 IPL Syllabus
PDF
CB19511 IPL Syllabus
B.Bhuvaneswaran, AP (SG) / CSE, REC: 13 January 2022
PDF
B.Bhuvaneswaran, AP (SG) / CSE, REC: 13 January 2022
Cloudsim Toolkit - Course Contents
PDF
Cloudsim Toolkit - Course Contents
Cloud Sim Manual
PDF
Cloud Sim Manual
CB19742 IT Workshop (Scilab Matlab)
PDF
CB19742 IT Workshop (Scilab Matlab)
CB19442 DT
PDF
CB19442 DT
CPP 05 PDF
PDF
CPP 05 PDF
MWA Syllabus
PDF
MWA Syllabus
CB19541 AAD Syllabus
PDF
CB19541 AAD Syllabus
CPP 01 PDF
PDF
CPP 01 PDF
CS19611 MADL Syllabus
PDF
CS19611 MADL Syllabus
CPP 02 PDF
PDF
CPP 02 PDF
IT6601 MC AU QP Reg 2013
PDF
IT6601 MC AU QP Reg 2013
CPP 03 PDF
PDF
CPP 03 PDF
CPP 04 PDF
PDF
CPP 04 PDF
CB19241-Data Structures and Algorithms-Syllabus
PDF
CB19241-Data Structures and Algorithms-Syllabus
C MCQ
PDF
C MCQ
Stack ADT
PDF
Stack ADT
CB19241-CSBS-Data Structures and Algorithms-Lab Syllabus
PDF
CB19241-CSBS-Data Structures and Algorithms-Lab Syllabus
CB19241-CSBS-Data Structure and Algorithms-Theory-Syllabus
PDF
CB19241-CSBS-Data Structure and Algorithms-Theory-Syllabus
Anna University - Dec - 2018 - Time Table
PDF
Anna University - Dec - 2018 - Time Table
OOPs Class Test - Answers
PDF
OOPs Class Test - Answers
Problem Solving and Python Programming Assignment - III
PDF
Problem Solving and Python Programming Assignment - III
CSS Important MCQ Questions
PDF
CSS Important MCQ Questions
C Basics Crossword Puzzle
PDF
C Basics Crossword Puzzle
Thingspeak IoT
PDF
Thingspeak IoT
01 Python Introduction
PDF
01 Python Introduction
CS6202 - PDS - I - Unit Test - I - Important Questions - Part - A
PDF
CS6202 - PDS - I - Unit Test - I - Important Questions - Part - A