
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

5K+ Views
Macro substitution is a mechanism that provides a string substitution. It can be achieved through "#deifne".It is used to replace the first part with the second part of the macro definition, before the execution of the program.The first object may be a function type or an object.SyntaxThe syntax for macros is as follows −#define first_part second_partProgramIn the program for every occurrence of first_part is replaced with the second_part throughout the code. Live Demo#include #define square(a) a*a int main(){ int b, c; printf("enter b element:"); scanf("%d", &b); c=square(b);//replaces c=b*b before execution of program printf("%d", c); return 0; }OutputYou will see the following ... Read More

10K+ Views
An array of characters (or) collection of characters is called a string.DeclarationRefer the declaration given below −char stringname [size];For example − char a[50]; string of length 50 characters.InitializationThe initialization is as follows −Using single character constant −char a[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}Using string constants −char a[10] = "Hello":;AccessingThere is a control string “%s” used for accessing the string, till it encounters ‘\0’.The logic used to count number of vowels is as follows −if(string[i]=='a'||string[i]=='e'||string[i]=='i'|| string[i]=='o'||string[i]=='u')//checking the char is vowel vowel=vowel+1;The logic used to count number of digits is as follows −if(string[i]=='0'||string[i]=='1'||string[i]=='2'|| string[i]=='3'||string[i]=='4'||string[i]=='5'|| string[i]=='6'||string[i]=='7'||string[i]=='8'||string[i]=='9') digit=digit+1;The logic used to ... Read More

416 Views
Let’s take the input of 3x3 matrix, means total 9 elements, in 2D array using keyboard at runtime.With the help of it and for loops, we can display only lower triangle in 3X3 matrix.The logic to print lower triangle elements is as follows −for(i=0;i=2nd index printf("%d",array[i][j]); else printf(" "); //display blank in non lower triangle places } printf(""); }ProgramFollowing is the C program to display only the lower triangle elements in a 3x3 2D array − Live Demo#include int main(){ int array[3][3],i,j; printf("enter 9 numbers:"); for(i=0;i

17K+ Views
An array is a group of related data items that are stored with single name.For example, int student[30];Here, student is an array name which holds 30 collection of data items, with a single variable name.OperationsThe operations of an array are explained below −Searching − It is used to find whether a particular element is present or not.Sorting − Helps in arranging the elements in an array either in ascending or descending order.Traversing − Processing every element in an array, sequentially.Inserting − Helps in inserting the elements in an array.Deleting − Helps in deleting an element in an array.In this program, ... Read More

10K+ Views
An array is a homogeneous sequential collection of data items over a single variable name.For example, int student[30];Here, student is an array name holds 30 collection of data item, with a single variable name.CharacteristicsThe characteristics of arrays are as follows −An array is always stored in consecutive memory location.It can store multiple value of similar type, which can be referred with single name.The pointer points to the first location of memory block, which is allocated to the array name.An array can either be an integer, character, or float data type that can be initialised only during the declaration.The particular element ... Read More

4K+ Views
The difference between monolithic programming and modular programming along with the advantages and disadvantage are explained below in detail.Monolithic programmingIf, we write an entire program in a single function that is in main function then, you call it as a monolithic type of programming. But, it is not a good style of writing entire logic in a single function.DisadvantagesThe disadvantages of monolithic programming include −Program seems to be very large and complex.Debugging, testing and maintenance of a program is very difficult.Modular ProgrammingIf the program is divided into number of functional parts, then we use to call it as modular programming.If ... Read More

1K+ Views
First, open the file in write mode. Later on, enter the text until it reaches the End Of File (EOF) i.e. press ctrlZ to close the file.Again, open in reading mode. Then, read words from the file and print each word in a separate line and close the file.The logic we implement to print one word per line is as follows −while ((ch=getc(fp))!=EOF){ if(fp){ char word[100]; while(fscanf(fp, "%s", word)!=EOF) // read words from file{ printf("%s", word); // print each word on separate lines. } ... Read More

1K+ Views
The structure is a user-defined data type, which is used to store a collection of different data types of data.The structure is similar to an array. The only difference is that an array is used to store the same data types whereas, the structure is used to store different data types.The keyword struct is for declaring the structure.Variables inside the structure are the members of the structure.A structure can be declared as follows −Struct structurename{ //member declaration };ExampleFollowing is the C program for accessing a structure variable − Live Demostruct book{ int pages; float price; char author[20]; ... Read More

614 Views
The pointer is a variable that stores the address of another variable.The syntax for the pointer is as follows −pointer = &variable;ExampleFollowing is the C program for the concept of pointers using C language − Live Demo#include void main(){ //Declaring variables and pointer// int a=2; int *p; //Declaring relation between variable and pointer// p=&a; //Printing required example statements// printf("Size of the integer is %d", sizeof (int));//4// printf("Address of %d is %d", a, p);//Address value// printf("Value of %d is %d", a, *p);//2// printf("Value of next address location of %d is %d", a, ... Read More