Found 1401 Articles for C

Difference between Compile Time Errors and Runtime Errors in C Program

Nitin Sharma
Updated on 18-Sep-2019 11:49:02

2K+ Views

Error or exception is something that refers to the interruption of code execution due to which the expected outcome could not be attained to the end-user.On the basis of the event when an error is generated or identified we can classify them as Compile time error and runtime error.The following are the important differences between Compile Time Errors and Runtime Errors.Sr. No.KeyCompile Time ErrorsRuntime Errors1ReferenceCompile-time errors are generally referred to the error corresponding to syntax or semantics.Runtime errors on the other hand refer to the error encountered during the execution of code at runtime.2DetectionCompile-time errors get detected by compiler at ... Read More

Difference between C and C++.

Mahesh Parahar
Updated on 19-Aug-2022 12:06:49

7K+ Views

C programming Language C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC PDP-11 computer in 1972. In 1978, Brian Kernighan and Dennis Ritchie produced the first publicly available description of C, now known as the K&R standard. The UNIX operating system, the C compiler, and essentially all UNIX application programs have been written in C. C has now become a widely used professional language for various reasons − Easy to learn Structured language It produces efficient programs ... Read More

Difference between Boxing and Unboxing in C# programming.

Nitin Sharma
Updated on 17-Sep-2019 11:06:03

528 Views

C# provides two methods to link value type to reference type and vice e Versa. These two methods for linking are named boxing and unboxing where Boxing is used for the conversion of the value type to an object type while Unboxing refers to the conversion of the object type to the value type.The following are the important differences between Boxing and Unboxing.Sr. No.KeyBoxingUnboxing1ImplementationBoxing made object type referred to as the value type.Unboxing basically processes the retrieving value from the boxed object.2StorageIn the case of boxing, the value stored on the stack is copied to the object stored on heap ... Read More

Print matrix in zag-zag fashion in C Programming.

Sunidhi Bansal
Updated on 04-Sep-2019 07:22:21

1K+ Views

Given a matrix mat[row][col] we have to print the given matrix in zig-zag fashion like in the given image below −So the output should be like −Output: 10 20 40 70 50 30 60 80 90For the above problem, we have followed a simple approach where we have to iterate the matrix diagonally and change the value of iteration to change the direction after every previous match.AlgorithmSTART STEP 1-> DECALRE AND SET k = 3, l = 3 STEP 2-> DECLARE A MATRIX mat[][3] STEP 3-> DECLARE AND SET row = 0, col = 0, flag = false; STEP 4-> ... Read More

Print matrix in snake pattern from the last column in C Programming.

Sunidhi Bansal
Updated on 04-Sep-2019 06:13:45

251 Views

Given an array of nxn size, the program must print the elements of an array in a snake pattern starting from the last column that means from arr[0][n]th element without doing any changes to their original locations.ExampleInput: arr[]= 100 99 98 97    93 94 95 96    92 91 90 89    85 86 87 88 Output: 97 98 99 100 96 95 94 93 92 91 90 89 88 87 86 85AlgorithmSTART Step 1 -> declare initial variable as int n to 5, i and j Step 2 -> declare array of 2-D matrix with elements Step 3 -> Loop For i=0 and i= 0; j--)             printf("%d ", arr[i][j]);       }    return 0; }Outputif we run the above program then it will generate the following output50 40 30 20 10 60 70 80 90 100 150 140 130 120 110 160 170 180 190 200 250 240 230 220 210

Print matrix in snake pattern in C Programming.

Sunidhi Bansal
Updated on 04-Sep-2019 06:08:53

3K+ Views

Given an array of nxn size, the program must print the elements of an array in a snake pattern without doing any changes to their original locationsExampleInput: arr[]= 100 99 98 97    93 94 95 96    92 91 90 89    85 86 87 88 Output: 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85The program will traverse each row of a matrix and check for even or odd rows.If the row is even it will print the elements of that row from left to rightIf the row is odd it ... Read More

Print shortest path to print a string on screen in C Program.

Sunidhi Bansal
Updated on 22-Aug-2019 09:14:49

204 Views

Given a string, the program must display the shortest path which will print the string over the screen using that shortest path.Like screen will store alphabets in the formatA B C D E F G H I J K L M N O P Q R S T U V W X Y ZExampleInput: HUP Output : Move Down Move Down Move Down destination reached Move Left Move Left Move Down Move Down Move Down destination reached Move Up destination reachedThe approach used here is to store the characters in the n x n matrix and perform the following operation ... Read More

Print sorted distinct elements of array in C language

Sunidhi Bansal
Updated on 22-Aug-2019 09:08:29

428 Views

Given with an array of integer elements, the task is to remove the duplicate values and print the distinct elements in sorted manner.Given below is an array that stores integer type values in the fashion 4, 6, 5, 3, 4, 5, 2, 8, 7 and 0 now, the result will print the sorted elements as 0, 2, 3, 4, 4, 5, 5, 6, 7 and 8 but this result still contains duplicate values 4 and 5 which should be removed and the final result will be 0, 2, 3, 4, 5, 6, 7 and 8ExampleInput: array[] = {4, 6, 5, ... Read More

Print numbers with digits 0 and 1 only such that their sum is N in C Program.

Sunidhi Bansal
Updated on 22-Aug-2019 09:09:48

224 Views

Given an integer n, the task is to print the numbers who consist only 0’s and 1’s and their sum is equal to the integer n.The numbers which contain only zeros and ones are 1, 10, 11 so we have to print all those numbers which can be added to form the sum equal to n.Like, we entered n = 31 then the answer can be 10+10+11 or 10+10+10+1 theExampleInput: 31 Output:10 10 10 1Algorithmint findNumbers(int n) START STEP 1: DECLARE AND ASSIGN VARAIBALES m = n % 10, a = n STEP 2: LOOP WHILE a>0    IF a/10 ... Read More

Print symmetric double triangle pattern in C language

Sunidhi Bansal
Updated on 22-Aug-2019 09:42:30

266 Views

Given with number of lines the program must print the symmetric double triangle pattern with least complexity.ExampleInput: 5 Output:  X           X           O X            O X     X O X O X        X O         X O          X           XThe entire problem contains 3 different partitions −Print upper half with n-1 lines for odd n or n-2 lines for even n.Print middle lines, 1 line for odd n or ... Read More

Advertisements