PPS LAB

Program to print Fibonacci Series

Fibonacci Series: It is a special series, where first term is 0 and second term is 1 and from third term onwards, every term is the sum of previous two terms.0 1 1 2 3 5 8 13 and so on….. Program (Without Function)Time Complexity: O(n)Space Compexity: O(1) #include <stdio.h> int main() { printf(“****************************************************************”); printf(“\n****************************************************************”); …

Program to print Fibonacci Series Read More »

Program to compare two strings

Program #include <stdio.h> #include<string.h> int main() { char str1[20],str2[20],str3[40]; int len; printf(“************************************************************”); printf(“\n************************************************************”); printf(“\n** WAP to compare two strings **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n************************************************************”); printf(“\n************************************************************”); printf(“\nenter the string1\n”); gets(str1); printf(“\nenter the string2\n”); gets(str2); if(strcmp(str1,str2)==0) printf(“\nBoth Strings are Equal”); else printf(“\nStrings are not Equal”); } …

Program to compare two strings Read More »

Program to concatenate one string into another string

Program #include <stdio.h> #include<string.h> int main() { char str1[20],str2[20],str3[40]; int len; printf(“************************************************************”); printf(“\n************************************************************”); printf(“\n** WAP to concatenate one string into another string **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n************************************************************”); printf(“\n************************************************************”); printf(“\nenter the string1\n”); gets(str1); printf(“\nenter the string2\n”); gets(str2); strcpy(str3,str1); strcat(str3,str2); printf(“\nConcatenated string is %s”, str3); } …

Program to concatenate one string into another string Read More »

Progarm to copy contents of a string into another string in C

Program #include <stdio.h> #include<string.h> int main() { char str1[20],str2[20]; int len; printf(“************************************************************”); printf(“\n************************************************************”); printf(“\n** WAP to copy contents of a string into another string **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n************************************************************”); printf(“\n************************************************************”); printf(“\nenter the string\n”); gets(str1); strcpy(str2,str1); printf(“\nAnother Copy of the string is %s”, str2); } …

Progarm to copy contents of a string into another string in C Read More »

Program to find the length of a string in C

Program #include <stdio.h> #include<string.h> int main() { char str[20]; int len; printf(“************************************************************”); printf(“\n************************************************************”); printf(“\n** WAP to enter a string and find its length in C **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n************************************************************”); printf(“\n************************************************************”); printf(“\nenter the string\n”); gets(str); len = strlen(str); printf(“\nLength of the string is %d”, …

Program to find the length of a string in C Read More »

Program to transpose a matrix / 2D array

Program Time Complexity: O(mn)Space Complexity: O(mn)where m and n are number of rows and columns in matrix #include <stdio.h> int main() { printf(“****************************************************”); printf(“\n****************************************************”); printf(“\n** WAP to transpose elements of a matrix/2D array **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n****************************************************”); printf(“\n****************************************************\n”); int m, n, i, j, …

Program to transpose a matrix / 2D array Read More »

Program to multiply two matrices / 2D arrays

Program Time Complexity: O(r1 * c1 * c2) Space Compexity: 0(1) where r1 and c1 are the number of rows and columns in matrix A, and r2 and c2 are the number of rows and columns in matrix B #include <stdio.h> int main() { printf(“****************************************************”); printf(“\n****************************************************”); printf(“\n** WAP to multiply two matrices or 2D arrays …

Program to multiply two matrices / 2D arrays Read More »

Program to subtract two matrices / 2D arrays

Program Time Complexity: O(m*n) where m and n are the number of rows and columns in matrix.Space Compexity: 0(1) m=max(r1,r2)n=max(c1,c2) #include <stdio.h> int main() { printf(“****************************************************”); printf(“\n****************************************************”); printf(“\n** WAP to subtract two matrices or 2D arrays **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n****************************************************”); printf(“\n****************************************************\n”); int r1, …

Program to subtract two matrices / 2D arrays Read More »

Program to add two matrices / 2D arrays

Program Time Complexity: O(m*n) where m and n are the number of rows and columns in matrix.Space Compexity: O(1)m=max(r1,r2)n=max(c1,c2) #include <stdio.h> int main() { printf(“****************************************************”); printf(“\n****************************************************”); printf(“\n** WAP to add two matrices or 2D arrays **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n****************************************************”); printf(“\n****************************************************\n”); int r1, c1, …

Program to add two matrices / 2D arrays Read More »

Program to find product of elements of a 2D array

Program #include <stdio.h> int main() { printf(“****************************************************”); printf(“\n****************************************************”); printf(“\n** WAP to find product of elements of a 2D array **”); printf(“\n** Created by Sheetal Garg **”); printf(“\n** Assistant Professor **”); printf(“\n** Phone No:9467863365 **”); printf(“\n****************************************************”); printf(“\n****************************************************\n”); int m, n, i, j, a[5][5], p = 1; printf(“Enter no. of rows and columns in the array\n”); scanf(“%d%d”, …

Program to find product of elements of a 2D array Read More »

error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.