note solve this problem without #include<stdlib.h> , #include<ctype.h> , #includ
ID: 3830503 • Letter: N
Question
note
solve this problem without #include<stdlib.h> , #include<ctype.h> , #include<string.h> and also without fgets , i want a simple way
simple example the way to solve problem
#include <stdio.h>
int main()
{
int numbers[10];
int pos[10], neg[10];
int i, j = 0, k = 0;
printf("Enter 10 Numbers: "); // -4 7 -8 1 -3 -9 55 22 33 99
for(i = 0; i < 10; i++)
scanf("%d", &numbers[i]);
for(i = 0; i < 10; i++)
{
if(numbers[i] >= 0)
{
pos[j] = numbers[i];
j++;
}
else
{
neg[k] = numbers[i];
k++;
}
}
// display both pos[] and neg[]
printf(" The Positive Array: ");
for(i = 0; i < j; i++)
printf("%d ", pos[i]);
printf(" The Negative Array: ");
for(i = 0; i < k; i++)
printf("%d ", neg[i]);
return 0;
}
ELEC330 Project SP17pdf-Adobe Acrobat Reader DC File Edit View Window Help Home Tools ELEC330 Project S... x Write a C program that gets a set of characters from the user and store it in a char array. The reading continues until two consecutive characters are detected. You may use the following declaration for your array char chars [50] If the array is not empty, then the program displays the following about the elements of the array: 1. The number of vowel characters. 2. The number of non-vowel characters. 3. The number of lower case letters. 4. The number of upper case letters. 5. The percentage of upper case letters of all letters. 6. The percentage of vowels of all characters. 7. The number of numerical characters. 8. The number of prime numbers. 9. All prime numbers in the input set. Notes Note 1: iftwo characters are entered at the begging of the input, the program will stop as shown in Fig.1. In this case, the array would be empty Enter A Set of Characters: Unfortunately, the array is empty! The program will stop now Fig 1 Sign In 5.16 PExplanation / Answer
#include<stdio.h>
int main()
{
//Declaring variables called i,size,vowel etc;
int i=0,size,vowel=0,ucletter=0,lcletter=0,numeric=0,prime=0;
char array[100];
while(1) //Open an infinity loop to build an arrau.
{
scanf("%c",&array[i]); //Reading character by character.
if(array[i]==' ') //When user click enter.
{
size=i;
break; //loop will terminate.
}
i++;
}
if(array[0]=='#' && array[1]=='#')
{
printf("The array is empty! The program will stop");
}
else
{
for(i=0;i<size;i++) //Repeating loop from array first index to last index;
{
//Checking if the value is vowel or not.
if(array[i]=='A' || array[i]=='a' || array[i]=='E' || array[i]=='e' || array[i]=='I' || array[i]=='i' || array[i]=='O' || array[i]=='o' || array[i]=='U' || array[i]=='u')
{
vowel++;
}
//Checking for upper case letters using their ASII values A=65 and Z=90
if(array[i]>=65 && array[i]<=90)
{
ucletter++;
}
//Checking for lower case letters using their ASII values a=97 and z=122
if(array[i]>=97 && array[i]<=122)
{
lcletter++;
}
//Checking for numeric value using their ASCII values 0=48 and 9=57
if(array[i]>=48 && array[i]<=57)
{
numeric++;
}
if(array[i]=='3' || array[i]=='7' || array[i]=='5')
{
prime++;
}
}
printf("The number of vowels in the list = %d ",vowel);
printf("The number of upper case letters in list = %d ",ucletter);
printf("The number of lower case letters in list= %d ",lcletter);
printf("The percentage of upper case letters of all letters = %f % ",(float)((float)ucletter/(float)size)*100);
printf("The percentage vowels of all letters = %f % ",(float)((float)vowel/(float)size)*100);
printf("The number of numeric values in list = %d ",numeric);
printf("The number of prime numbers in list= %d ",prime);
printf("The percentage of prime numbers of all letters = %f % ",(float)((float)prime/(float)size)*100);
}
return 0;
}
OUTPUT :-
HelloHai 1234 23
The number of vowels in the list = 4
The number of upper case letters in list = 2
The number of lower case letters in list= 6
The percentage of upper case letters of all letters = 12.500000
The percentage vowels of all letters = 25.000000
The number of numeric values in list = 6
The number of prime numbers in list= 2
The percentage of prime numbers of all letters = 12.500000
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.