Source Code Create a value with Confidence...

Prgramming Language : C

C Program to Find Largest Number using Dynamic Memory Allocation

Program

Output

/* Author : Mr. V. A. Kanjariya Website : www.SourceCodeInfoTech.co.in E-Mail : support@SourceCodeInfoTech.co.in ©2015 All Copy Rights reserved by Source Code Info Tech Pvt. Ltd. */ //C Program to Find Largest Element Using Dynamic Memory Allocation //=====Source Code===== #include <stdio.h> #include <stdlib.h> int main() { int i,n; float *data; printf("Enter total number of elements(1 to 100): "); scanf("%d",&n); data=(float*)calloc(n,sizeof(float)); /* Allocates the memory for 'n' elements */ if(data==NULL) { printf("Error!!! memory not allocated."); exit(0); } printf("\n"); for(i=0;i<n;++i) /* Stores number entered by user. */ { printf("Enter Number %d: ",i+1); scanf("%f",data+i); } for(i=1;i<n;++i) /* Loop to store largest number at address data */ { if(*data<*(data+i)) /* Change < to > if you want to find smallest number */ *data=*(data+i); } printf("Largest element = %.2f",*data); return 0; } Enter total number of elements(1 to 100): 10 Enter Number 1: 2.34 Enter Number 2: 3.43 Enter Number 3: 6.78 Enter Number 4: 2.45 Enter Number 5: 7.64 Enter Number 6: 9.05 Enter Number 7: -3.45 Enter Number 8: -9.99 Enter Number 9: 5.67 Enter Number 10: 34.95 Largest element: 34.95

Learn more Concept in Programing in C


* Introduction
* Hello World
* Data Types
* Variable
* Constants
* #define
* Storage Classes
* Sizeof()
* The ? : Operator
* Conditional Operator
* Arithmetic Operators
* Relational Operators
* Logical Operators
* Bitwise Operators
* Assignment Operators
* Increment Operator
* Decrement Operator
* Logical bitwise Operator
* Shift Operator
* simple if
* if...else
* if...else if...else
* if...else if ladder
* Nested if
* switch...case

* Nested switch...case
* while loop
* for loop
* do...while loop
* nested for loops
* nested While loops
* nested do...while loops
* break statement
* continue statement
* goto statement
* The Infinite Loop
* User Define Function
* call by value Function
* call by Reference Function
* Function no argument,no return Type
* Function argument,no return Type
* Function no argument,return Type
* Function argument,return Type
* Local Variables
* Global Variables
* One-Dimensional Arrays
* Two-Dimensional Arrays
* Multi-Dimensional Arrays
* Passing Arrays as Function Arguments
* Return Array from Function

* Pointer to an Array
* Pointers
* NULL Pointer
* Incrementing a Pointer
* Decrementing a Pointer
* Pointer Comparisons
* Array of pointers
* Pointer to Pointer
* Passing pointers to functions
* Return pointer from functions
* strcpy(s1, s2) - Copy String
* strcat(s1, s2) - Concate String
* strlen(s1) - Length of String
* strcmp(s1, s2) - Compare String
* strchr(s1, ch) - Match String
* strstr(s1, s2) - Match String
* Structure
* Structures as Function Arguments
* Pointers to Structures
* Union
* Typedef
* Auto Variable
* External Variable
* Satic Variable
* Register Variable

* File I/O
* Getc()
* Putc()
* FGets()
* FPuts()
* Fscanf()
* Fprintf()
* Fread()
* Fwrite()
* Malloc()
* Calloc()
* Ftell()
* rewind()
* getchar()
* putchar()
* gets()
* puts()
* scanf()
* printf()


Learn Programming Language


* Android
* ASP.NET
* AngularJS
* AJAX ToolKit
* BootStrap

* Programing C
* Programing C++
* Programing C#
* CSS
* CSS-3

* HTML
* HTML-5
* Java
* JavaScript
* PHP

* J-Query
* J-QueryUI
* JQuery-Grid
* JQuery-Chart
* Crystal Report

* LISP
* MS-Word
* MS-PowerPoint
* MS-Excel
* SQLite

* MySQL
* Oracle
* Python
* Pl/SQL

* SQL Server
* VB.NET
* VBScript
* Visual Basic

Free Download Final Year Project


* Android
* ASP.NET
* GAMES

* AngularJS
* BootStrap
* WINDOWS

* Programing C
* Programing C++
* WEBSITE

* Programing C#
* Java
* MS-Access

* PHP
* MySQL

* Oracle
* SQL

* VB.NET
* Visual Basic