Design an algorithm, draw a corresponding flowchart and then write a program in C to convert a given string to lower case. 10m Jun2008

By | July 24, 2015

Design an algorithm, draw a corresponding flowchart and then write a program in C to convert a given string to lower case. 10m Jun2008

 

Algorithm

Step 1: Input String

Step 2: Initilise Pointer C to initial character of String

Step 3: while(C != NULL)

{

if (*C>=’A’ && *C<=’Z’)

{

*C=*C+32

}
Step 4: Print converted Lower case String

Step 5: Stop

 FlowChart:

FlowChart_Lower_Case

Program Search S:-

#include<stdio.h>
void main()
{
char S[50],*C;
clrscr();
printf(“\nENTER STRING TO CONVERT TO LOWERCASE : “);
scanf(“%s”,&S);
C=S[0];
while(C != NULL)
{
if(*C>=’A’ && *C<=’Z’)
*C=*C+32;
C++;
}
printf(“\nCONVERTED LOWERCASE STRING IS :- %s”,S);
getch();
}

[codesyntax lang=”c”]

#include<stdio.h>
void main()
{
char S[50],*C;
clrscr();
printf(“\nENTER STRING TO CONVERT TO LOWERCASE : “);
scanf(“%s”,&S);
C=S[0];
while(C != NULL)
{
if(*C>=’A’ && *C<=’Z’)
*C=*C+32;
C++;
}
printf(“\nCONVERTED LOWERCASE STRING IS :- %s”,S);
getch();
}

[/codesyntax]

Screen Shots:

C_program_Convert_Lower_Case

C_program_Convert_Lower_Case_Out

 

(b) Write an algorithm and program in C to generate fibonacci series. Use recursion. 10m Jun2008

Solved program can be found on this link http://cssimplified.com/c-programming/a-c-program-to-find-the-fibonacci-series-of-numbers-using-recursion

 

(c) Draw a flowchart and write a program in C to calculate the number of vowels in a given string. 10m Jun2008

Solved program can be found on this link http://cssimplified.com/c-programming/a-c-program-to-count-number-of-vowels-consonants-spaces-in-a-given-string

 

(d) What do you mean by ‘array of pointers’? Write a program in C to calculate the difference of the corresponding elements of two arrays of integers of same size. 10m Jun2008

Array of pointers

 The way there can be an array of integers, or an array of float numbers, similarly, there can be array of pointers too. Since a pointer contains an address, an array of pointers would be a collection of addresses. For example, a multidimensional array can be expressed in terms of an array of pointers rather than a pointer to a group of contiguous arrays.

4 5 6

7 8 9

Two-dimensional array can be defined as a one-dimensional array of integer pointers by writing:

int *arr[3];

 rather than the conventional array definition,

 int arr[3][5];

Solved program can be found on this link http://cssimplified.com/c-programming/an-interactive-c-program-to-add-two-matrices-or-subtract-two-matrices