Skip to main content

Sample C Program to accept two string and compare the strings are equal or not.

46) Sample C Program to count the number of words, characters, alphabets, vowels, consonants and digit in a line of text.

# include <stdio.h>
# include <conio.h>

main( )
int noa = 0, nob = 0, noc = 0, nov =0 , now = 0, noch = 0, l, I;
char ch, s[100];
clrscr( );
printf("Enter 2 lines of text:");

l = strlen(s);

for(i = 0; i < 1; i++)
           case 'a':
           case 'e':
           case 'i':
           case 'o':
           case 'u':
           case 'A':
           case 'E':
           case 'I':
           case 'O':
           case 'U':



      if(noa[i] == ' ') && (noa[i + 1] != ' ')


noch = l - nob;
noc = noa - nov;

printf("Total no of words %d", now);
printf("Total no of characters(without blanks)%d", noch);
printf("Total no of characters(including blanks)%d", l);
printf("Total no of alphabets %d", noa);
printf("Total no of vowels %d", nov);
printf("Total no of characters %d", noc);
printf("Total no of digits %d", nod);
getch( );

47) Sample C Program to accept two string and compare the strings are equal or not.

# include <stdio.h>
# include <conio.h>

int getline (char line[ ], int lim );
int strc(char str1[ ], char str2[] );

main( )
char str1[80],
str2[80]; int comp;
clrscr( );

printf("Enter first string:");
getline(str1, 80);

printf("Enter second string:");
getline(str2, 80);

comp = strc(str1, str2);

if(comp > 0)
   printf("First string is bigger.");
else if(comp == 0)
   printf("Both the strings are equal.");

getch( );

int getline(char str[], int lin)
int i;
for(i = 0; i < lin && ( (str[i] = getchar()) != '\n'); i++);
if(str[i] = '\0')
return i;

int strc(char str1[], char str2[])
int i;
for(i = 0; str1[i]; i++)
if(str1[i] != str2[i])
return str1[i] - str2[i];
return str1[i] - str2[i];

48) Sample C Program to sort the entered numbers using bubble sort.

# include <stdio.h>
# include <conio.h>
main( )

int a[100], i, j, n, t;
clrscr( );

printf("Enter the array size:");

for(i = 1; i < n; i++)
    scanf("%d", &a[i]);

for(i = 1; i <= n; i++)
    for(j = i + 1; j < n; j++)
        if(a[i] > a[j])
            t = a[i]
            a[i] = a[j];
            a[j] = t;

printf("The sorted elements are:");

for(i = 1; i <= n; i++)
    print("%d", a[i]);

getch( );


- C Program To Implement Minimum Spanning Tree Using Functions, Pointers & Structures.

- C Program To Implement 8 Queens Problem Using Arrays, Pointers & Functions.

- C Program To Implement Quick Sort Using Pointers, Functions & Arrays.

- C Program To Implement Binary Search Without Using Recursive Function.

- C Program To Implement Binary Search Using Recursive Function.

...Back To C Program Index.


Popular posts from this blog

Tell Me Something About Yourself - Interview Answers.

Try to introduce some of your most important employment-oriented skills as well as your education and accomplishments to the interviewer. Answer to this question is very important because it positions you for the rest of the interview. That's why this statement is often called the "Positioning Statement".

One should take the opportunity to show his/her communication skills by speaking clearly and concisely in an organized manner. Since there is no right or wrong answer for this question hence it is important to appear friendly.


1) I am a person with strong interpersonal skills and have the ability to get along well with people. I enjoy challenges and looking for creative solutions to problems.

2) Besides the details given in my resume, I believe in character values, vision and action. I am quick in learning from mistakes. I am confident that the various tests that you have conducted will corroborate my competencies aptitude and right attitude for the…

100 C Programs Frequently Asked in Technical Interview.

Why Should We Hire You? - Interview Answers

The interviewer asks this question just to find out how your skills, experience and knowledge can add value to the job.Well to answer this question you need to learn what they are looking for and then tie them with your strengths. This ensures that you are a viable fit for the position.

The more detail you give the stronger your answers will be. Try to summarize all your accomplishments and relate what makes you unique.

The question can also be

"Why should we hire you over other candidates?"
"Why should we hire you over the others waiting to be interviewed?"

Your answers can be:

1) You should hire me because I’m the best person for the job. I realize that there are likely other candidates who also have the ability to do this job. Yet I bring an additional quality that makes me the best person for the job - my passion for excellence. I am passionately committed to producing truly class results.

2) I believe I’m the perfect fit for this position. I’m very detai…