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
Server Side Programming Articles - Page 1253 of 2650
700 Views
ProblemWhat is the logic in C language to print the numbers in different formats like pyramid, right angle triangle?SolutionTo print the numbers or symbols in different model we can take the help of for loop in the code.Example1Following is the C program to print pyramid − Live Demo#include int main(){ int n; printf("Enter number of lines: "); scanf("%d", &n); printf(""); // loop for line number of lines for(int i = 1; i
19K+ Views
Let’s take the concept of arrays to about compile time and run time initialization −ArrayArray is a collection of items stored at contiguous memory locations and elements can access by using indices.Compile time array initializationIn compile time initialization, user has to enter the details in the program itself.Compile time initialization is same as variable initialization. The general form of initialization of array is as follows −Syntaxtype name[size] = { list_of_values }; //integer array initialization int rollnumbers[4]={ 2, 5, 6, 7}; //float array initialization float area[5]={ 23.4, 6.8, 5.5, 7.3, 2.4 }; //character array initialization char name[9]={ 'T', 'u', 't', 'o', ... Read More
2K+ Views
ProblemCompiler not reading the string after integer in C programming? How can we solve this problem?SolutionWhen you enter an integer number and press enter to read next value, compiler stores null into the string’s first char and string input terminates. Because scanf will terminate whenever it reads a null character.How to Solve It?When we are trying to read string or character after int or float, we should read a temporary char which is present in the input buffer.The following is the program without errors −Example Live Demo#include struct student{ char name[10]; int roll; char temp; } s; ... Read More
1K+ Views
ProblemCommon error occurred while reading string and numeric data using scanf() function in C languageSolutionThe scanf() function is used to read formatted input from stdin in C language. It returns the whole number of characters written in it otherwise, returns a negative value.Generally in case of scanf() function while reading string values after integer from the user, we get frequent errors.ExampleFollowing is a C program which reads roll number (integer value) and name of a student − Live Demo#include struct student { char name[10]; int roll; } s; int main(){ printf("Enter information of students:"); printf("Enter roll ... Read More
8K+ Views
ProblemTry to print a name 10 times without using any loop or goto statement in C programming language.SolutionGenerally, looping statements are used to repeat the block of code until condition is false.Example1In this program, we are trying to print a name 10 times without using loop or goto statements. Live Demo#include void printname(char* name,int count){ printf("%03d : %s",count+1,name); count+=1; if(count
5K+ Views
Yes, we can give arguments in the main() function.Command line arguments in C are specified after the name of the program in the system’s command line, and these argument values are passed on to your program during program execution.The argc and argv are the two arguments that can pass to main function.But main() function is actually called by the operating system (or shell program) when you run the program from the terminal.SyntaxThe syntax is explained below −int main(int argc, char *argv[]){ //Code return 0; }Example Live Demo#include int main(int argc, char *argv[]){ int i; for (i = ... Read More
531 Views
Implicit type conversion is done by the compiler by converting smaller data type into a larger data type.For example, ASCII value of A=65.In this program, we are giving character ‘A’ as input, now write a code to convert A to 65 which is its ASCII value.ExampleFollowing is the example to find ASCII value of uppercase character ‘A’ using implicit conversion − Live Demo#include int main(){ char character = 'A'; int number = 0, value; value = character + number; //implicit conversion printf("The ASCII value of A is: %d", value); return 0; }OutputThe ASCII value of ‘A’ ... Read More
32K+ Views
Type conversions change an expression from one data type to another. conversions can utilize many features of type hierarchies or data representation. Implicit type conversion Explicit type conversion Implicit Type Conversion Implicit type conversions, also known as type casting or type transformation, are automatic type conversions performed by the compiler. Most programming languages have compilers that handle type transformation automatically. When operands are of different data types, the compiler automatically performs implicit type conversions by converting the smaller data type into a larger one. int i, x; float f; double ... Read More
5K+ Views
Process of Creating and Running ProgramsA program contains a set of instructions which was written in a programming language.The programmer’s job is to write and test the program.The 4 steps to convert a ‘C’ program into machine language are &miuns;Writing and editing the programCompiling the programLinking the programExecuting the programWriting and editing the program‘Text editors’ are used to write programs.With the help of text editors, users can enter, change and store character data.All special text editors are often included with a compiler.After writing the program, the file is saved to disk.It is known as ‘source file’.This file is input to ... Read More
934 Views
Assume, you have ‘products.csv’ file and the result for a number of rows and columns and ‘product’ column value matches ‘Car’ for the first ten rows are −Download the products.csv file here.Rows: 100 Columns: 8 id product engine avgmileage price height_mm width_mm productionYear 1 2 Car Diesel 21 16500 1530 1735 2020 4 5 Car Gas 18 17450 ... Read More