
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1339 Articles for C

1K+ Views
ProblemIn C language, is the program executed, if we use an uninitialized array?SolutionIf we use any uninitialized array, compiler will not generate any compilation and an execution error.If an array is uninitialized, you may get unpredictable result.So, it’s better we should always initialize the array elements with default values.Example ProgramFollowing is the C program of accessing an uninitialized array − Live Demo#include int main(void){ int a[4]; int b[4] = {1}; int c[4] = {1,2,3,4}; int i; //for loop counter //printing all alements of all arrays printf("Array a:"); for( i=0; i

3K+ Views
Suppose you have an array with four elements. Then, an array indexing will be from 0 to 3, i.e., we can access elements from index 0 to 3.But, if we use index which is greater than 3, it will be called as an index out of bounds.If, we use an array index which is out of bounds, then the compiler will compile and even run. But, there is no guarantee for the correct result.Result can be not sure and it will start causing many problems. Hence, it is advised to be careful while using an array indexing.Example ProgramFollowing is the ... Read More

895 Views
Passing entire structure as an argument to function −Name of the structure variable is given as argument in function call.It is collected in another structure variable in function header.DisadvantageA copy of the entire structure is created again wasting memoryProgramFollowing program demonstrates passing an entire structure as an argument to function − Live Demo#include //Declaring structure// struct add{ int var1; int var2; }a; //Declaring and returning Function// void show(struct add a){ //Declaring sum variable// int sum; //Arithmetic Operation// sum=a.var1+a.var2; //Printing O/p// printf("Added value is %d", sum); } void main(){ //Declaring structure// struct ... Read More

1K+ Views
ProblemCan we declare a structure with no members in C, if yes what will be the size of that structure?SolutionYes, it is allowed in C programming language that we can declare a structure without any member and in that case the size of the structure with no members will be 0 (Zero). It will be a Zero size structure.Example Live Demo#include //structure with no members struct temp{ }; int main(){ //declaring structure variable struct temp T; printf("Size of T: %d", sizeof(T)); return 0; }OutputIn this C program, we are declaring a structure named "temp" without declare ... Read More

184 Views
The atoi() is predefined function used to convert a numeric string to its integer value.Create a customized atoi()The atoi() only converts a numeric string to integer value, so we need to check the validity of the string.If this function encounters any non-numeric character in the given string, the conversion from string to integer will be stopped.Example Live Demo#include #include #include int main(){ int value; char string1[] = "3567"; value = atoi(string1); printf("String value = %s", string1); printf("Integer value = %d", value); char string2[] = "TutorialsPoint"; value = atoi(string2); printf("String value ... Read More

777 Views
Following is the logic we implement to find alphabets, digits and special characters −for(number=0;string[number]!='\0';number++) {// for loop until endof string if(string[number]>='a'&&string[number]='A'&&string[number]='0'&&string[number]='a'&&string[number]='A'&&string[number]='0'&&string[number]

249 Views
Character analysis and conversion functionsThe predefined functions in “ctype.h” library is for analyzing the character input and converting them.Analysis functionsS.NoFunctionDescription1isalpha()An alphabet or not2isdigit()A digit or not3isspace()A space, a new line or tab4ispunct()A special symbol or not5slower()A lower case letter of alphabet6isupper()An upper case letter of alphabet7isalphanumeric()An alphabet/digit or notConverting functionsFunctionDescriptiontolower()Converts an upper case alphabet to lower casetoupper()Converts a lower case alphabet to upper caseExampleLet us see a program to demonstrate character analysis and conversion functions − Live Demo#include #include void main(){ //Initializing compile time character variable// char variable = 'A'; //Reading User I/P// //printf("Enter the character : "); ... Read More

296 Views
The strlen () functionIt returns the number of characters in a string.Syntaxint strlen (string name)In this program, with the help of gets function reading the name at run time and trying to print the length of that name using strlen() function, this function returns an integer value and try to print that no using printf.Example 1 Live Demo#include #include void main(){ //Declaring string and length// char name[25]; int length; //Reading Input from user// printf("Enter your name : "); gets(name); length=strlen(name); //Printing name// printf("Your name is : "); puts(name); printf("Length of ... Read More

448 Views
Pointer is a variable which stores the address of other variable.Features of PointersFollowing are the features of pointers −Saves the memory spaceExecution time is faster because of direct access to memory location.The memory is accessed efficiently with the pointer i.e. dynamically memory is allocated and deallocated.Pointers are used with data structures.Here is an example for search demonstration −We can access and print a particular character in a string by using pointers.Following example shows how to access the elements using pointer −Example Live Demo#include int main(){ char array[5] = "Tutorial", *ptr, i, *ptr1; ptr = &array[1]; ptr1 = ptr ... Read More

1K+ Views
ProblemWrite a C program to calculate sum and product of all elements in two-dimensional array using run time compilation.SolutionRuntime compilation or initialization is also called as dynamic allocation. Allocation of memory at the time of execution (run time) is known as dynamic memory allocation.The functions calloc() and malloc() support allocating of dynamic memory.In this program, we will calculate the sum of all elements and product of all elements of two-dimensional array at run time.Logic for computing sum of all elements in 2D array −printf("Sum array is : "); for(i=0;i