0% found this document useful (0 votes)
17 views2 pages

String Length Without String Function

The document describes several C programming examples: 1) Adding two matrices using a function that performs element-wise addition. 2) Calculating the length of a string without using string functions by incrementing a counter as each character is read. 3) Checking if a number is perfect by summing its factors and comparing to the original number. 4) Finding prime numbers between 1 and 100 by checking if a number is only divisible by 1 and itself. 5) Transposing a matrix using dynamic memory allocation with malloc and free.

Uploaded by

deepikaaruna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

String Length Without String Function

The document describes several C programming examples: 1) Adding two matrices using a function that performs element-wise addition. 2) Calculating the length of a string without using string functions by incrementing a counter as each character is read. 3) Checking if a number is perfect by summing its factors and comparing to the original number. 4) Finding prime numbers between 1 and 100 by checking if a number is only divisible by 1 and itself. 5) Transposing a matrix using dynamic memory allocation with malloc and free.

Uploaded by

deepikaaruna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Matrix addition using functions

1.
2.
3.
4.

enter the row and column for first matrix


Enter the elements for matrix 1.
Get the row and column for matrix2
Get the values for matrix 2

Call the function addmatrix() and perform the addition operation d[i][j]=a[i][j]+b[i][j];
5. on two matrices
6. Display the resultant matrix.

String length without string function.


Get the string from user.
Initialize the length=0;
Read the character one by one until reach the NULL. Increment the length value
Initialize length = 0. Compute the string length by incrementing length value by 1 for every
Character in the string.
Display the value of length.
Perfect no:
get the number from user
intialize i=1
check num%i equal to 0 then sum=sum+i
repeate this procedure until the condition i<num will fail
if sum equal to number then the number is perfect
otherwise the number is not perfect.Perform
prime no between 1 to 100.

Set the input range from 1 to 100


Check whether the number %i=0 then increment the count value.
Repeat the same procedure until the condition i=num/2 will fail

if count equal to 0 and number not equal to 1 then the number is prime no and display that
number
dynamic mem for matrix transpose
Read the row and column value from the user.
allocate memory space for row and column using malloc() function.
get the elements for matrix a[i][j]
transpose of matrix a[j][i] change row as columns and colunm as row and display the
elemnts in matrix a.
remove the memory space for matrix a. using free() function

sub string:
read the string from user.
get the substring you want to search.
read the character from given string untill reach the NULL.
compare the substring character one by one with string .
if flag equal to 1 then the substring is present in the string otherwise the sub string is not
present.

get the string from user using gets() function.


read the character one by one until reach the NULL.
if the charcter is a or e or i or o or u then incement the vowels.
if the character ia greater than a and less than z incremnet the consonents.
if the chatacter ia a gertarte than 0 and less than 9
then incremt the digit value,
if the chataccter is an blank space then incremt the white sapce value.
diaplay all vowels,consonent,digits an dwhite sapace.

You might also like