How to write a C Program to Maximum count of chars, Maximum count of numbers and Maximum count of signs in C Programming Language ?
This C Program to Max count of chars, Max count of nums and Max count of signs.
Solution:
- #include <stdio.h>
- #include <conio.h>
- void main() {
- int chars=0, nums=0, mchars=0, mnums=0, signs=0, msigns = 0, i;
- char str[500];
- puts("Input string:");
- gets(str);
- for (i = 0; str[i]; i++) {
- if (str[i] >= '0' && str[i] <= '9') {
- nums++;
- if (chars > mchars) mchars = chars;
- if (signs > msigns) msigns = signs;
- chars = signs = 0;
- }
- else {
- if (nums > mnums) mnums = nums;
- nums = 0;
- if ((str[i] >= 'a' && str[i] <= 'z') ||
- (str[i] >= 'A' && str[i] <= 'Z')) {
- chars++;
- if (signs > msigns) msigns = signs;
- signs = 0;
- }
- else if (str[i] == '*' || str[i] == '+' || str[i] == '-'){
- signs++;
- if (chars > mchars) mchars = chars;
- chars = 0;
- }
- else {
- if (chars > mchars) mchars = chars;
- if (signs > msigns) msigns = signs;
- }
- }
- }
- if (nums > mnums) mnums = nums;
- if (chars > mchars) mchars = chars;
- if (signs > msigns) msigns = signs;
- printf("Max count of chars: %d\nMax count of nums: %d\nMax count of signs: %d\n", mchars, mnums, msigns);
- printf("Is chars count bigger than signs count: "); printf(mchars > msigns ? "true" : "false");
- _getch();
- }
Learn More :
Number
- Find out the perfect number using c program
- Write a c program to find out H.C.F. of two numbers.
- Check the given number is armstrong number or not using c program.
- Write a c program to find largest among three numbers using conditional operator
- FIND OUT GENERIC ROOT OF A NUMBER - C PROGRAM.
- FIND PRIME FACTORS OF A NUMBER USING C PROGRAM
- How To Write a C program that generates two random numbers ?
- Write a C program to find maximum or equal between two numbers ?
- How to Write a C program to find maximum between two numbers ?
- Write a C program to perform math operations on two input whole numbers. The operations are:
- Write a C program to find maximum between three numbers ?
- Sort Three Numbers - program reads in three Integers and displays them in ascending order.
- C Program to Enter an ODD number between 1 and 49.
- C program acquires keyboard 10 numbers for each of these numbers to determine if it is a first issue, by printing immediately message should at the end, if none of the numbers you entered was a first issue, print an appropriate message.
- C program generates a random number and uses an algorithm to generate 9 other numbers.
- C Program to Find Random Number
- C Program To Find LCM and HCF Of Two Number Using Function - 2
- C Program to find LCM and HCF Of Two Number Using Recursion - 3
- C Program To Find LCM and HCF Of Two Number -1
- C Program To Find Reverse Of Any Digit Number
- C Program To Find The Frequency Of A Number
- C Program To Print Prime Numbers Upto The Number You Want
- C Program To Print Sum Of n Digit Number
- C Program To Reverse A Number
- C Program To Search A Number Inside The Array
Count
- C Program String - Alphabet Count Example
- C Program String Count Example
- Write the procedure , which is one of a sum , a product and a geometric average in the panel for the NxM elements are located on opposite diagonal and main diagonal . Remind ! Counting only odd elements !
- C Program Array NxM Elements Geometric/Arithmetic
- C Program to Count Number of Lines in Input until Interrupted by CTRL + Z
- Returns: array of decoded values. [0] - count of values
- C Program to Count Vowels, Consonants and Spaces in a string
- C Program to count number of sentences words and letters in a paragraph
- Un-sortiertes Array and Sortiertes Array
- C Program to Count Change Program
- LED ON OFF For One Sec/Count and Display on the Attached Serial Monitor
- Menu driven program in C which performs the following operations on strings
- C program to accept n number from user,store these numbers into an array & count the no of occurrences of each number
Maximum
- Write a C program to find maximum or equal between two numbers ?
- How to Write a C program to find maximum between two numbers ?
- Write a C program to find maximum between three numbers ?
- C program to Given a vector (integer or real), determine what is the maximum value of element what is the position in which this element is located
- C Program To Find The Maximum And Minimum Value In An Array
- C Program To Find Maximum Of Given Numbers
- C Program to Print Maximum and Minimum Number in Row and Column
- C Program to Find max and min in array using pointer concept
- C Program to accept n numbers from user & find out the maximum element out of them by using dynamic memory allocation
- C Program to accept n numbers from user, store these numbers into an array. Find out Maximum & Minimum number from an Array
Minimum
- C Program To Find The Maximum And Minimum Value In An Array
- C Program to Print Maximum and Minimum Number in Row and Column
- C Program to Find max and min in array using pointer concept
- C Program to accept n numbers from user, store these numbers into an array. Find out Maximum & Minimum number from an Array
signs