
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
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

7K+ 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

516 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

31K+ 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

4K+ Views
Lambda Function − Lambda are functions is an inline function that doesn’t require any implementation outside the scope of the main program.Lambda Functions can also be used as a value by the variable to store. Lambda can be referred to as an object that can be called by the function (called functors).Whenever the compiler encounters a definition of the lambda function, it generally creates a custom object for the lambda.A lambda function has more functionality than a normal function, for example, it has a capturing method to capture the used variables. However, the captured variable is treated as the member ... Read More

9K+ Views
Suppose we have a string s. We have to check whether the given string is a palindrome or not. We have to solve this problem using pointers in C.So, if the input is like s = "racecar", then the output will be True.To solve this, we will follow these steps −length := size of stringforward := pointing to the first character of stringreverse := pointing to the last character of stringwhile position of reverse >= position of forward, doif character pointed by reverse is same as character pointed by forward, thenincrease forward and decrease reverse by 1otherwisecome out from loopif ... Read More

316 Views
In this section we will see when we declare a variable that is un-initialized, then which value they hold in C or C++ language.What Happens When You Don’t Initialize Variables? In C and C++, when a variable is declared inside a function (i.e., as a local variable) but not explicitly initialized, it holds an undefined or garbage value. This means the variable may contain any value that is present at that memory location.Unlike some high-level languages where variables are automatically initialized (e.g., 0 for integers, false for booleans), C and C++ do not initialize local variables by default. So, assuming ... Read More

230 Views
We are given the number N and coordinates of two points (x1, y1) and (x2, y2) for each line. The goal is to find the maximum number of lines from given lines that can pass through a single point such that no two lines cover each other, and no rotation is performed.We will represent lines as pair of (m, c) where y=mx+c and m is slope m=y2-y1/x2-x1Lines with same m are parallel given c1!=c2. We will count distinct slopes(m). For vertical lines if x1=x2, slope = INT_MAX else m.Let us understand with an example.Input Line 1 (x1, y1)=(4, 10) (x2, y2)=(2, ... Read More