Skip to main content

C Program to find even ,odd numbers and their sum and average

Below program will accept the range for example 62 to 70. Program will count all even and odd numbers from range 62 to 70 and perform sum of even and odd numbers respectively. It also provide average of odd and even numbers.

// Program Name: Accept Range from user and then find even odd numbers with sum and average respectively.
#include<stdio.h>
 
void main()
{
 int startNum=0,endNum=0,i=0,eNoCnt=0,oNoCnt=0,eSum=0,oSum=0;
 
 printf("\n\t Provide Range of number to identify even number as requested for e.g 56 90");
 printf("\n\n\n\t Please provide Range\t");
 scanf("%d", &startNum);
 scanf("%d", &endNum);

 for(i = startNum; i < endNum; i ++)
 {
   if(i % 2 == 0)
   {
     eNoCnt++;
     eSum=eSum+i;
   }
   else
   {
     oNoCnt++;
     oSum=oSum+i;
   }
 }
  
 printf("\n\t Total Number of Even Numbers are = %d ", eNoCnt);
 printf("\n\t Total of Even number is %d",eSum);
 printf("\n\t Average of Even Number is %d",eSum/eNoCnt);
 printf("\n\n\t Total Number of Odd Numbers are = %d ", oNoCnt);
 printf("\n\t Total of Odd number is %d",oSum);
 printf("\n\t Average of Odd Number is %d",oSum/oNoCnt);
}

Output

Please provide Range   1
500

         Total Number of Even Numbers are = 249 
         Total of Even number is 62250
         Average of Even Number is 250

         Total Number of Odd Numbers are = 250 
         Total of Odd number is 62500
         Average of Odd Number is 250

C Program to find length of string with or without function

//Program Name: To find length of the string with and without function.

#include<stdio.h>
#include<string.h>
void main()
{
char str[250]; //to store entered string
int cnt;  //counter

printf("\n\tEnter a string to check length:" );
gets(str);

for(cnt = 0; str[cnt] != '\0'; ++cnt);

printf("\n\t Length of string without using function: %d", cnt);

printf("\n\t Length of string with strlen function %d",strlen(str));

}

Output

Enter a string to check length:Learning C
Length of string without using function: 10
	 Length of string with strlen function 10

Python code to check if character is alphabet or number

Below python code will identify character whether it is alphabet or number using comparison and built in function like isalpha, isdigit


# Program to check if character is alphabet or not.

#Take user input and store it in variable ch
ch = input("Enter a character to check if character is alphabet or not: ")
#comparing characters with a to Z or A to Z 

if((ch>='a' and ch<= 'z') or (ch>='A' and ch<='Z')):
    print(ch, "is an Alphabet")
else:
    print(ch, "is not an Alphabet")

# using IsAlpha function
if (ch.isalpha()):
    print(ch, "is an Alphabet identified using Is ALPHA function")
else:
    print(ch, "is not an Alphabet")

# using IS digit function
if(ch.isdigit()):
    print(ch, "is an number identified using IS Digit function")
   
Enter a character to check if character is alphabet or not: 
5
5 is not an Alphabet
5 is not an Alphabet
5 is an number identified using IS Digit function

   
Enter a character to check if character is alphabet or not: 
s
s is an Alphabet
s is an Alphabet identified using Is ALPHA function

C Program to Identify Even Odd numbers from user input.

Below program will first accept total number which user want to enter. Then user has to enter numbers one by one.

Program will identify even and Odd numbers and store their total count in variable.

// Program Name: Accept n numbers from user and then identify even or odd Numbers
#include<stdio.h>
 
void main()
{
 int totalNum, i, ary[100];
 int eNoCnt = 0, oNoCnt = 0;
 
 printf("\n\t Enter the Size of an Array (total numbers)  :  \t");
 scanf("%d", &totalNum);
 
 printf("\n\t Enter the Numbers to identify even numbers\t");
 for(i = 0; i < totalNum; i++)
 {
   scanf("%d", &ary[i]);
 }
  
 for(i = 0; i < totalNum; i ++)
 {
   if(ary[i] % 2 == 0)
   {
     eNoCnt++;
   }
   else
   {
     oNoCnt++;
   }
 }
  
 printf("\n\t Total Number of Even Numbers are = %d ", eNoCnt);
 printf("\n\t Total Number of Odd Numbers are = %d ", oNoCnt);
}


	 Enter the Size of an Array (total numbers)  :  	6



	 Enter the Numbers to identify even numbers	1

2

3

4

5

6



	 Total Number of Even Numbers are = 3 

	 Total Number of Odd Numbers are = 3 

Program to print Odd Numbers till user input

// Program to print odd numbers from 1 to n
#include <stdio.h>
int main() {
    int range;
    printf("Enter range of number to print odd numbers");
    scanf("%d",&range);
      printf("Odd Numbers from 1 to %d are \n",range);
    for(int i =1;i<=range;i++)
    {
        if (i%2 != 0)
        printf("\t%d",i);
    }
    return 0;
}

Output

Enter range of number to print odd numbers   15
Odd Numbers from 1 to 15 are 
	1	3	5	7	9	11	13	15

Program to Print Even Numbers till User Input

// Program to print even numbers from 1 to n
#include <stdio.h>
int main() {
    int range;
    printf("Enter range of number to print even numbers  ");
    scanf("%d",&range);
      printf("Even numbers from  1 to %d are \n",range);
    for(int i =1;i<=range;i++)
    {
        if (i%2 ==  0)
        printf("\t%d",i);
    }
    return 0;
}

Output

Enter range of number to print even numbers  15
Even numbers from  1 to 15 are 
	2	4	6	8	10	12	14

List of Public API for Continuous Integration, Cloud Storage & File Sharing

APIDescriptionLinkAuth
Abstract Public HolidaysData on national, regional, and religious holidays via APIhttps://www.abstractapi.com/holidays-apiapiKey
Calendar IndexWorldwide Holidays and Working Dayshttps://www.calendarindex.com/apiKey
Google CalendarDisplay, create and modify Google calendar eventshttps://developers.google.com/google-apps/calendar/OAuth
HolidaysHistorical data regarding holidayshttps://holidayapi.com/apiKey
Non-Working DaysDatabase of ICS files for non working dayshttps://github.com/gadael/icsdb 
UnixTime ConverterA REST API to convert UnixTime to DateTime and DateTime to UnixTimehttps://unixtime.co.za 
AnonFilesUpload and share your files anonymouslyhttps://anonfiles.com/docs/api 
BayFilesUpload and share your fileshttps://bayfiles.com/docs/api 
BoxFile Sharing and Storagehttps://developer.box.com/OAuth
DropboxFile Sharing and Storagehttps://www.dropbox.com/developersOAuth
File.ioSuper simple file sharing, convenient, anonymous and securehttps://www.file.io 
GoFileUnlimited size file uploads for freehttps://gofile.io/apiapiKey
Google DriveFile Sharing and Storagehttps://developers.google.com/drive/OAuth
OneDriveFile Sharing and Storagehttps://dev.onedrive.com/OAuth
PantryFree JSON storage for small projectshttps://getpantry.cloud/ 
PastebinPlain Text Storagehttps://pastebin.com/doc_apiapiKey
Web3 StorageFile Sharing and Storage for Free with 1TB Spacehttps://web3.storage/apiKey
CircleCIAutomate the software development process using continuous integration and continuous deliveryhttps://circleci.com/docs/api/v1-reference/apiKey
CodeshipCodeship is a Continuous Integration Platform in the cloudhttps://apidocs.codeship.com/apiKey
Travis CISync your GitHub projects with Travis CI to test your code in minuteshttps://docs.travis-ci.com/api/apiKey
Continuous Integration and Cloud Storage public api list.

Data credit for https://github.com/davemachado/public-api#get-random

To fetch Latest List of new or updated API visit this github link for more information which retrieve all public api information for below categories.

List of Public API available for various category like Animals Anime, Anti-Malware, Art & Design, Authentication, Books, Business, Calendar, Cloud Storage & File Sharing, Continuous Integration, Cryptocurrency, Currency Exchange, Data Validation, Development, Dictionaries, Documents & Productivity Environment, Events, Finance, Food & Drink, Games & Comics, Geocoding, Health, Jobs, Machine Learning, Music, News, Open Data, Open Source Projects, Patent, Personality, Phone, Photography, Science & Math, Security, Shopping, Social, Sports & Fitness, Test Data, Text Analysis, Tracking, Transportation, URL Shorteners, Vehicle, Video, Weather,

New list of Public API for Books, Business category

Below is the list of public API for books and business category. More information on documentation is available after visiting the link in Link Column.

APIDescriptionLinkAuth
British National BibliographyBookshttp://bnb.data.bl.uk/ 
Crossref Metadata SearchBooks & Articles Metadatahttps://github.com/CrossRef/rest-api-doc 
Google BooksBookshttps://developers.google.com/books/OAuth
LibGenLibrary Genesis search enginehttps://garbage.world/posts/libgen/ 
New York Times BooksBook reviews and The New York Times Best Sellers listshttps://developer.nytimes.com/docs/books-product/1/overviewapiKey
Open LibraryBooks, book covers and related datahttps://openlibrary.org/developers/api 
Penguin PublishingBooks, book covers and related datahttp://www.penguinrandomhouse.biz/webservices/rest/ 
Wolne LekturyAPI for obtaining information about e-books available on the WolneLektury.pl websitehttps://wolnelektury.pl/api/ 
Charity SearchNon-profit charity datahttp://charityapi.orghunter.com/apiKey
Clearbit LogoSearch for company logos and embed them in your projectshttps://clearbit.com/docs#logo-apiapiKey
Domainsdb.infoRegistered Domain Names Searchhttps://domainsdb.info/ 
FreelancerHire freelancers to get work donehttps://developers.freelancer.comOAuth
GmailFlexible, RESTful access to the user’s inboxhttps://developers.google.com/gmail/api/OAuth
Google AnalyticsCollect, configure and analyze your data to reach the right audiencehttps://developers.google.com/analytics/OAuth
mail.tmTemporary Email Servicehttps://docs.mail.tm 
MailboxValidatorValidate email address to improve deliverabilityhttps://www.mailboxvalidator.com/api-email-freeapiKey
mailgunEmail Servicehttps://www.mailgun.com/apiKey
markerapiTrademark Searchhttp://www.markerapi.com/ 
ORB IntelligenceCompany lookuphttps://api.orb-intelligence.com/docs/apiKey
SmartsheetAllows you to programmatically access and Smartsheet data and account informationhttps://smartsheet.redoc.ly/OAuth
SwiftKanbanKanban software, Visualize Work, Increase Organizations Lead Time, Throughput & Productivityhttps://www.digite.com/swiftkanban/apiKey
TrelloBoards, lists and cards to help you organize and prioritize your projectshttps://developers.trello.com/OAuth
Books and Business public API

Data credit for https://github.com/davemachado/public-api#get-random

List of Public API Information for Anime, Anti-Malware, Authentication

List of public free APIs for Anime, Anti-Malware, Art & Design, Authentication. With Details like API Name, Description, Link, and Authentication type.

APIDescriptionLinkAuth
AniAPIAnime discovery, streaming & syncing with trackershttps://github.com/AniAPI-Team/AniAPIOAuth
AniDBAnime Databasehttps://wiki.anidb.net/HTTP_API_DefinitionapiKey
AniListAnime discovery & trackinghttps://github.com/AniList/ApiV2-GraphQL-DocsOAuth
AnimeChanAnime quotes (over 10k+)https://github.com/RocktimSaikia/anime-chan 
AnimeNewsNetworkAnime industry newshttps://www.animenewsnetwork.com/encyclopedia/api.php 
JikanUnofficial MyAnimeList APIhttps://jikan.moe 
KitsuAnime discovery platformhttps://kitsu.docs.apiary.io/OAuth
MyAnimeListAnime and Manga Database and Communityhttps://myanimelist.net/clubs.php?cid=13727OAuth
NekosBestNeko Images & Anime roleplaying GIFshttps://docs.nekos.best 
ShikimoriAnime discovery, tracking, forum, rateshttps://shikimori.one/api/docOAuth
Studio GhibliResources from Studio Ghibli filmshttps://ghibliapi.herokuapp.com 
Waifu.picsImage sharing platform for anime imageshttps://waifu.pics/docs 
AbuseIPDBIP/domain/URL reputationhttps://docs.abuseipdb.com/apiKey
AlienVault Open Threat Exchange (OTX)IP/domain/URL reputationhttps://otx.alienvault.com/apiapiKey
Google Safe BrowsingGoogle Link/Domain Flagginghttps://developers.google.com/safe-browsing/apiKey
MalShareMalware Archive/file sourcinghttps://malshare.com/doc.phpapiKey
MetacertMetacert Link Flagginghttps://metacert.com/apiKey
URLhausBulk queries and Download Malware Sampleshttps://urlhaus-api.abuse.ch/ 
URLScan.ioScan and Analyse URLshttps://urlscan.io/about-api/apiKey
VirusTotalVirusTotal File/URL Analysishttps://www.virustotal.com/en/documentation/public-api/apiKey
Art Institute of ChicagoArthttps://api.artic.edu/docs/ 
ColourLoversGet various patterns, palettes and imageshttp://www.colourlovers.com/api 
Cooper HewittSmithsonian Design Museumhttps://collection.cooperhewitt.org/apiapiKey
DribbbleDiscover the world’s top designers & creativeshttps://developer.dribbble.comOAuth
EuropeanaEuropean Museum and Galleries contenthttps://pro.europeana.eu/resources/apis/searchapiKey
Harvard Art MuseumsArthttps://github.com/harvardartmuseums/api-docsapiKey
Icon HorseFavicons for any website, with fallbackshttps://icon.horse 
IconfinderIconshttps://developer.iconfinder.comapiKey
Icons8Iconshttp://docs.icons8.apiary.io/#reference/0/metaOAuth
Metropolitan Museum of ArtMet Museum of Arthttps://metmuseum.github.io/ 
Noun ProjectIconshttp://api.thenounproject.com/index.htmlOAuth
PHP-NoiseNoise Background Image Generatorhttps://php-noise.com/ 
Pixel EncounterSVG Icon Generatorhttps://pixelencounter.com/api 
RijksmuseumArthttps://www.rijksmuseum.nl/en/apiapiKey
Auth0Easy to implement, adaptable authentication and authorization platformhttps://auth0.comapiKey
Micro User ServiceUser management and authenticationhttps://m3o.com/userapiKey
MojoAuthSecure and modern passwordless authentication platformhttps://mojoauth.comapiKey
StytchUser infrastructure for modern applicationshttps://stytch.com/apiKey
Public API List

Data credit

List of Public API for Animals

List of Public API for Animals

APIDescriptionAuthHTTPSCorsLink
AxolotlCollection of axolotl pictures and factstrueunknownhttps://theaxolotlapi.netlify.app/
Cat FactsDaily cat factstruenohttps://alexwohlbruck.github.io/cat-facts/
CataasCat as a service (cats pictures and gifs)trueunknownhttps://cataas.com/
catAPIRandom pictures of catstrueyeshttps://github.com/ThatCopy/catAPI/wiki/Usage
CatsPictures of cats from TumblrapiKeytrueunknownhttps://docs.thecatapi.com/
Dog FactsRandom dog factstrueunknownhttps://dukengn.github.io/Dog-facts-API/
DogsBased on the Stanford Dogs Datasettrueyeshttps://dog.ceo/dog-api/
HTTPCatCat for every HTTP Statustrueunknownhttps://http.cat/
IUCNIUCN Red List of Threatened SpeciesapiKeyfalseunknownhttp://apiv3.iucnredlist.org/api/v3/docs
MovebankMovement and Migration data of animalstrueunknownhttps://github.com/movebank/movebank-api-doc
PlaceBearPlaceholder bear picturestrueyeshttps://placebear.com/
PlaceDogPlaceholder Dog picturestrueyeshttps://place.dog
RandomCatRandom pictures of catstrueyeshttps://aws.random.cat/meow
RandomDogRandom pictures of dogstrueyeshttps://random.dog/woof.json
RandomDuckRandom pictures of duckstruenohttps://random-d.uk/api
RandomFoxRandom pictures of foxestruenohttps://randomfox.ca/floof/
RescueGroupsAdoptiontrueunknownhttps://userguide.rescuegroups.org/display/APIDG/API+Developers+Guide+Home
Shibe.OnlineRandom pictures of Shiba Inu, cats or birdstrueyeshttp://shibe.online/

Data credit for https://github.com/davemachado/public-api#get-random

C Program to count total vowel, consonant in sentence

This program will accept input from user. and then by iterating each character from sentence it will count number of vowel and consonant. “A”, “E”,”I”,”O”,”U” either in upper or lower case character are vowels. Other than “A”, “E”,”I”,”O”,”U” all characters between A to Z are consonant.

//Program Name: C Program to count vowel, consonant 

#include<stdio.h>
#include<string.h>
 void main()
 {
   char str[50],ch; //defining variable to accept input
   int chCount=0,cCnt=0,vCount=0;

    printf("\n\tEnter string to count vowel, consonant:\t");
    gets(str); // Read input in "str" variable
    

  while (str[chCount] != '\0')
  {
      ch=str[chCount];
      
   if((ch >= 'a' && ch <= 'z') || (ch >= 'A' &&ch <= 'Z'))
   {
       if(ch=='a'||ch=='i'||ch=='o'||ch=='u'||ch=='e' ||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
	       vCount=vCount+1;
	    else
	       cCnt=cCnt+1;
   }
    chCount++;
 }

 printf("\nNumber of vowels in given sentence are :%d \t ",vCount);
 printf("\nNumber of Consonants in given sentence are : %d \t ",cCnt);
 }

Output

Enter string to count vowel, consonant: This is software C
Number of vowels in given sentence are :5
Number of Consonants in given sentence are : 10

Program will read sentence in variable str. Every sentence end with ‘\0’ so we are iterating sentence character by character till we not receive ‘\0’. as we need to increment while count manually hence we are using chCount++; Each character is then getting compared with vowels and then associated variable counter is also getting incremented by one.

Click here for another program for vowel and consonants https://ethosspace.com/programmers/c-program-to-check-if-vowel-or-consonant/