MCS-011 Problem Solving and Programming Free Solved Assignment

IGNOU MCS-011-Problem Solving and Programming, Latest Solved Assignment (July 2023 - January 2024 )

ignoustudymentor.com

Q4. Write interactive C programs to perform the following on strings:

(a) To find the length of a given string without using the string library functions.

(b) To compare two strings without using string library functions.

(c)To count the total number of vowels and consonants in a string and display the counts separately.

Ans. (a) To find the length of a given string without using the string library functions.

// C program to find length of the string without using strlen() function
#include <stdio.h>
int main()
{
char s[100];
int i;
printf(“Enter a string: “);
scanf(“%s”, s);
for(i = 0; s[i] != ‘\0’; ++i);
printf(“Length of string: %d”, i);
return 0;
}

(b) To compare two strings without using string library functions.

#include <stdio.h>
#include <string.h>
int main()
{
char Str1[100], Str2[100];
int result, i;

printf(“\n Please Enter the First String : “);
gets(Str1);

printf(“\n Please Enter the Second String : “);
gets(Str2);

for(i = 0; Str1[i] == Str2[i] && Str1[i] == ‘\0’; i++);

if(Str1[i] < Str2[i])
{
printf(“\n str1 is Less than str2”);
}
else if(Str1[i] > Str2[i])
{
printf(“\n str2 is Less than str1”);
}
else {
printf(“\n str1 is Equal to str2”);
}
return 0;
}

(c) To count the total number of vowels and consonants in a string and display the counts separately.

#include <stdio.h>
#include <string.h>
#define MAX_SIZE 100 // Maximum string size

int main()
{
char str[MAX_SIZE];
int i, len, vowel, consonant;

/* Input string from user */
printf(“Enter any string: “);
gets(str);

vowel = 0;
consonant = 0;
len = strlen(str);

for(i=0; i<len; i++)
{
if((str[i]>=’a’ && str[i]<=’z’) || (str[i]>=’A’ && str[i]<=’Z’))
     {
      if(str[i] ==’a’ || str[i]==’e’ || str[i]==’i’ || str[i]==’o’ || str[i]==’u’ || str[i] ==’A’ || str[i]==’E’ || str[i]==’I’ || str[i]==’O’ ||                  str[i]==’U’ ) 
      vowel++;
      else
      consonant++;
     }
 }

     printf(“Total number of vowel = %d\n”, vowel);
     printf(“Total number of consonant = %d\n”, consonant);
return 0;
}

ignoustudymentor.com

MCS-011

Handwriting Assignment

MCS-011

Other Questions With Answers

Other Subjects

Click Here

Assignment Submission Last Date

The IGNOU open learning format requires students to submit study Assignments. Here is the final end date of the submission of this particular assignment according to the university calendar.

30th April (if Enrolled in the June Exams)

31st October (if Enrolled in the December Exams)

Student Quick Services

error: Content is protected !!