Write a program that calculate maximum number and it’s index in c

Here is the program that calculate the maximum number and it’s index in c.

This program is quite easy but confusing when you write carelessly because I am also careless in using format specifier for unsigned long long integer so that I have done mistake but you don’t need to get worry but clap this article or like or login in this article don’t forget to follow me:

#include <stdio.h>
#define N 5

int main(void){
unsigned long long int arr[N];
unsigned long long int i, maxIndex, maxNum;

for(i = 0; i < N; i++){
printf(“Enter %lld number with the index %lld: “, i + 1, i);
scanf(“%ll7d”, &arr[i]);
}
maxIndex = 0;
maxNum = arr[0];

for(i = 1; i < N; i++){
if(arr[i] > arr[maxIndex]){
maxIndex = i;
maxNum = arr[i];
}
}
printf(“Index of max digit is: %lld whereas max digit is %lld\n”, maxIndex, maxNum);

return 0;
}

Thanks you from “Himal Aryal”

--

--

--

Hey internet family, it’s your friend.. I am a c programmer and Welcome to my blog where I provide you c programming codes for free of cost no ads will shown

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Code to Customer: Simplifying Backend Tooling With Monorepo

Dynamics 365 Best Practices — Web resource dependencies

Code reading Interviews

IS Test-Driven Development (TDD) really important to practice?

AndroIdiots Podcast 11: Functional & Reactive Programming

To change tomorrow, we should learn today!

PostgreSQL — Slow count query

Evergreen Cloud Computing Trends to Uplift Your Business

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Haster

Haster

Hey internet family, it’s your friend.. I am a c programmer and Welcome to my blog where I provide you c programming codes for free of cost no ads will shown

More from Medium

Doja Code

Zoe C, Assignment 2

Understanding programming concepts for non-programmers

Ansi-color.cmd: Is Windows Batch Scripting a Programming Language?

A grid of foreground and background colors showing the resulting combinations