• C Data Types
  • C Operators
  • C Input and Output
  • C Control Flow
  • C Functions
  • C Preprocessors
  • C File Handling
  • C Cheatsheet
  • C Interview Questions

C Exercises – Practice Questions with Solutions for C Programming

The best way to learn C programming language is by hands-on practice. This C Exercise page contains the top 30 C exercise questions with solutions that are designed for both beginners and advanced programmers. It covers all major concepts like arrays, pointers, for-loop, and many more.

C-Exercises

So, Keep it Up! Solve topic-wise C exercise questions to strengthen your weak topics.

C Programming Exercises

The following are the top 30 programming exercises with solutions to help you practice online and improve your coding efficiency in the C language. You can solve these questions online in GeeksforGeeks IDE.

Q1: Write a Program to Print “Hello World!” on the Console.

In this problem, you have to write a simple program that prints “Hello World!” on the console screen.

For Example,

Click here to view the solution.

Q2: write a program to find the sum of two numbers entered by the user..

In this problem, you have to write a program that adds two numbers and prints their sum on the console screen.

Q3: Write a Program to find the size of int, float, double, and char.

In this problem, you have to write a program to print the size of the variable.

Q4: Write a Program to Swap the values of two variables.

In this problem, you have to write a program that swaps the values of two variables that are entered by the user.

Swap-two-Numbers

Swap two numbers

Q5: Write a Program to calculate Compound Interest.

In this problem, you have to write a program that takes principal, time, and rate as user input and calculates the compound interest.

Q6: Write a Program to check if the given number is Even or Odd.

In this problem, you have to write a program to check whether the given number is even or odd.

Q7: Write a Program to find the largest number among three numbers.

In this problem, you have to write a program to take three numbers from the user as input and print the largest number among them.

Q8: Write a Program to make a simple calculator.

In this problem, you have to write a program to make a simple calculator that accepts two operands and an operator to perform the calculation and prints the result.

Q9: Write a Program to find the factorial of a given number.

In this problem, you have to write a program to calculate the factorial (product of all the natural numbers less than or equal to the given number n) of a number entered by the user.

Q10: Write a Program to Convert Binary to Decimal.

In this problem, you have to write a program to convert the given binary number entered by the user into an equivalent decimal number.

Q11: Write a Program to print the Fibonacci series using recursion.

In this problem, you have to write a program to print the Fibonacci series(the sequence where each number is the sum of the previous two numbers of the sequence) till the number entered by the user using recursion.

FIBONACCI-SERIES

Fibonacci Series

Q12: Write a Program to Calculate the Sum of Natural Numbers using recursion.

In this problem, you have to write a program to calculate the sum of natural numbers up to a given number n.

Q13: Write a Program to find the maximum and minimum of an Array.

In this problem, you have to write a program to find the maximum and the minimum element of the array of size N given by the user.

Q14: Write a Program to Reverse an Array.

In this problem, you have to write a program to reverse an array of size n entered by the user. Reversing an array means changing the order of elements so that the first element becomes the last element and the second element becomes the second last element and so on.

reverseArray

Reverse an array

Q15: Write a Program to rotate the array to the left.

In this problem, you have to write a program that takes an array arr[] of size N from the user and rotates the array to the left (counter-clockwise direction) by D steps, where D is a positive integer. 

Q16: Write a Program to remove duplicates from the Sorted array.

In this problem, you have to write a program that takes a sorted array arr[] of size N from the user and removes the duplicate elements from the array.

Q17: Write a Program to search elements in an array (using Binary Search).

In this problem, you have to write a program that takes an array arr[] of size N and a target value to be searched by the user. Search the target value using binary search if the target value is found print its index else print ‘element is not present in array ‘.

Q18: Write a Program to reverse a linked list.

In this problem, you have to write a program that takes a pointer to the head node of a linked list, you have to reverse the linked list and print the reversed linked list.

Q18: Write a Program to create a dynamic array in C.

In this problem, you have to write a program to create an array of size n dynamically then take n elements of an array one by one by the user. Print the array elements.

Q19: Write a Program to find the Transpose of a Matrix.

In this problem, you have to write a program to find the transpose of a matrix for a given matrix A with dimensions m x n and print the transposed matrix. The transpose of a matrix is formed by interchanging its rows with columns.

Q20: Write a Program to concatenate two strings.

In this problem, you have to write a program to read two strings str1 and str2 entered by the user and concatenate these two strings. Print the concatenated string.

Q21: Write a Program to check if the given string is a palindrome string or not.

In this problem, you have to write a program to read a string str entered by the user and check whether the string is palindrome or not. If the str is palindrome print ‘str is a palindrome’ else print ‘str is not a palindrome’. A string is said to be palindrome if the reverse of the string is the same as the string.

Q22: Write a program to print the first letter of each word.

In this problem, you have to write a simple program to read a string str entered by the user and print the first letter of each word in a string.

Q23: Write a program to reverse a string using recursion

In this problem, you have to write a program to read a string str entered by the user, and reverse that string means changing the order of characters in the string so that the last character becomes the first character of the string using recursion. 

Reverse-a-String

reverse a string

Q24: Write a program to Print Half half-pyramid pattern.

In this problem, you have to write a simple program to read the number of rows (n) entered by the user and print the half-pyramid pattern of numbers. Half pyramid pattern looks like a right-angle triangle of numbers having a hypotenuse on the right side.

Q25: Write a program to print Pascal’s triangle pattern.

In this problem, you have to write a simple program to read the number of rows (n) entered by the user and print Pascal’s triangle pattern. Pascal’s Triangle is a pattern in which the first row has a single number 1 all rows begin and end with the number 1. The numbers in between are obtained by adding the two numbers directly above them in the previous row.

pascal-triangle

Pascal’s Triangle

Q26: Write a program to sort an array using Insertion Sort.

In this problem, you have to write a program that takes an array arr[] of size N from the user and sorts the array elements in ascending or descending order using insertion sort.

Q27: Write a program to sort an array using Quick Sort.

In this problem, you have to write a program that takes an array arr[] of size N from the user and sorts the array elements in ascending order using quick sort.

Q28: Write a program to sort an array of strings.

In this problem, you have to write a program that reads an array of strings in which all characters are of the same case entered by the user and sort them alphabetically. 

Q29: Write a program to copy the contents of one file to another file.

In this problem, you have to write a program that takes user input to enter the filenames for reading and writing. Read the contents of one file and copy the content to another file. If the file specified for reading does not exist or cannot be opened, display an error message “Cannot open file: file_name” and terminate the program else print “Content copied to file_name”

Q30: Write a program to store information on students using structure.

In this problem, you have to write a program that stores information about students using structure. The program should create various structures, each representing a student’s record. Initialize the records with sample data having data members’ Names, Roll Numbers, Ages, and Total Marks. Print the information for each student.

We hope after completing these C exercises you have gained a better understanding of C concepts. Learning C language is made easier with this exercise sheet as it helps you practice all major C concepts. Solving these C exercise questions will take you a step closer to becoming a C programmer.

Frequently Asked Questions (FAQs)

Q1. what are some common mistakes to avoid while doing c programming exercises.

Some of the most common mistakes made by beginners doing C programming exercises can include missing semicolons, bad logic loops, uninitialized pointers, and forgotten memory frees etc.

Q2. What are the best practices for beginners starting with C programming exercises?

Best practices for beginners starting with C programming exercises: Start with easy codes Practice consistently Be creative Think before you code Learn from mistakes Repeat!

Q3. How do I debug common errors in C programming exercises?

You can use the following methods to debug a code in C programming exercises Read the error message carefully Read code line by line Try isolating the error code Look for Missing elements, loops, pointers, etc Check error online

Please Login to comment...

Similar reads, improve your coding skills with practice.

 alt=

What kind of Experience do you want to share?

  • C Programming Home
  • ▼C Programming Exercises
  • Basic Declarations and Expressions
  • Basic Part-II
  • Basic Algorithm
  • Variable Type
  • Input - Output
  • Conditional Statements
  • Do-While Loop
  • Linked List
  • Callback function
  • Variadic function
  • Inline Function
  • File Handling
  • Searching and Sorting

C Basic: Exercises, Practice, Solution

C basic declarations and expressions [150 exercises with solution].

[ An editor is available at the bottom of the page to write and execute the scripts.   Go to the editor ]

1. Write a C program to print your name, date of birth, and mobile number. Expected Output :

Click me to see the solution

2. Write a C program to get the C version you are using. Expected Output :

3. Write a C program to print a block F using the hash (#), where the F has a height of six characters and width of five and four characters. And also print a very large 'C'. Expected Output :

4. Write a C program to print the following characters in reverse. Test Characters : 'X', 'M', 'L' Expected Output : The reverse of XML is LMX Click me to see the solution

5. Write a C program to compute the perimeter and area of a rectangle with a height of 7 inches and width of 5 inches. Expected Output : Perimeter of the rectangle = 24 inches Area of the rectangle = 35 square inches Click me to see the solution

6. Write a C program to compute the perimeter and area of a circle with a given radius. Expected Output : Perimeter of the Circle = 37.680000 inches Area of the Circle = 113.040001 square inches Click me to see the solution

7. Write a C program to display multiple variables. Sample Variable s : a+ c, x + c,dx + x, ((int) dx) + ax, a + x, s + b, ax + b, s + c, ax + c, ax + ux Declaration : int a = 125, b = 12345; long ax = 1234567890; short s = 4043; float x = 2.13459; double dx = 1.1415927; char c = 'W'; unsigned long ux = 2541567890; Click me to see the solution

8. Write a C program to convert specified days into years, weeks and days. Note: Ignore leap year. Test Data : Number of days : 1329 Expected Output : Years: 3 Weeks: 33 Days: 3 Click me to see the solution

9. Write a C program that accepts two integers from the user and calculates the sum of the two integers. Test Data : Input the first integer: 25 Input the second integer: 38 Expected Output: Sum of the above two integers = 63 Click me to see the solution

10. Write a C program that accepts two integers from the user and calculates the product of the two integers. Test Data : Input the first integer: 25 Input the second integer: 15 Expected Output: Product of the above two integers = 375 Click me to see the solution

11. Write a C program that accepts two item's weight and number of purchases (floating point values) and calculates their average value. Test Data : Weight - Item1: 15 No. of item1: 5 Weight - Item2: 25 No. of item2: 4 Expected Output: Average Value = 19.444444 Click me to see the solution

12. Write a C program that accepts an employee's ID, total worked hours in a month and the amount he received per hour. Print the ID and salary (with two decimal places) of the employee for a particular month. Test Data : Input the Employees ID(Max. 10 chars): 0342 Input the working hrs: 8 Salary amount/hr: 15000 Expected Output: Employees ID = 0342 Salary = U$ 120000.00 Click me to see the solution

13. Write a C program that accepts three integers and finds the maximum of three. Test Data : Input the first integer: 25 Input the second integer: 35 Input the third integer: 15 Expected Output: Maximum value of three integers: 35 Click me to see the solution

14. Write a C program to calculate a bike’s average consumption from the given total distance (integer value) travelled (in km) and spent fuel (in litters, float number – 2 decimal points). Test Data : Input total distance in km: 350 Input total fuel spent in liters: 5 Expected Output: Average consumption (km/lt) 70.000 Click me to see the solution

15. Write a C program to calculate the distance between two points. Test Data : Input x1: 25 Input y1: 15 Input x2: 35 Input y2: 10 Expected Output: Distance between the said points: 11.1803 Click me to see the solution

16. Write a C program to read an amount (integer value) and break the amount into the smallest possible number of bank notes. Test Data : Input the amount: 375 Expected Output: There are: 3 Note(s) of 100.00 1 Note(s) of 50.00 1 Note(s) of 20.00 0 Note(s) of 10.00 1 Note(s) of 5.00 0 Note(s) of 2.00 0 Note(s) of 1.00 Click me to see the solution

17. Write a C program to convert a given integer (in seconds) to hours, minutes and seconds. Test Data : Input seconds: 25300 Expected Output: There are: H:M:S - 7:1:40 Click me to see the solution

18. Write a C program to convert a given integer (in days) to years, months and days, assuming that all months have 30 days and all years have 365 days. Test Data : Input no. of days: 2535 Expected Output: 6 Year(s) 11 Month(s) 15 Day(s) Click me to see the solution

19. Write a C program that accepts 4 integers p, q, r, s from the user where q, r and s are positive and p is even. If q is greater than r and s is greater than p and if the sum of r and s is greater than the sum of p and q print "Correct values", otherwise print "Wrong values". Test Data : Input the second integer: 35 Input the third integer: 15 Input the fourth integer: 46 Expected Output: Wrong values Click me to see the solution

20. Write a C program to print the roots of Bhaskara’s formula from the given three floating numbers. Display a message if it is not possible to find the roots. Test Data : Input the first number(a): 25 Input the second number(b): 35 Input the third number(c): 12 Expected Output: Root1 = -0.60000 Root2 = -0.80000 Click me to see the solution

21. Write a C program that reads an integer and checks the specified range to which it belongs. Print an error message if the number is negative and greater than 80. Test Data : Input an integer: 15 Expected Output: Range [0, 20] Click me to see the solution

22. Write a C program that reads 5 numbers and sums all odd values between them. Test Data : Input the first number: 11 Input the second number: 17 Input the third number: 13 Input the fourth number: 12 Input the fifth number: 5 Expected Output: Sum of all odd values: 46 Click me to see the solution

23. Write a C program that reads three floating-point values and checks if it is possible to make a triangle with them. Determine the perimeter of the triangle if the given values are valid. Test Data : Input the first number: 25 Input the second number: 15 Input the third number: 35 Expected Output: Perimeter = 75.0 Click me to see the solution

24. Write a C program that reads two integers and checks whether they are multiplied or not. Test Data : Input the first number: 5 Input the second number: 15 Expected Output: Multiplied! Click me to see the solution

25. Write a C program that reads an integer between 1 and 12 and prints the month of the year in English. Test Data : Input a number between 1 to 12 to get the month name: 8 Expected Output: August Click me to see the solution

26. Write a C program that prints all even numbers between 1 and 50 (inclusive). Test Data : Even numbers between 1 to 50 (inclusive): Expected Output: 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 Click me to see the solution

27. Write a C program that reads 5 numbers and counts the number of positive numbers and negative numbers. Test Data : Input the first number: 5 Input the second number: -4 Input the third number: 10 Input the fourth number: 15 Input the fifth number: -1 Expected Output: Number of positive numbers: 3 Number of negative numbers: 2 Click me to see the solution

28. Write a C program that reads 5 numbers, counts the number of positive numbers, and prints out the average of all positive values. Test Data : Input the first number: 5 Input the second number: 8 Input the third number: 10 Input the fourth number: -5 Input the fifth number: 25 Expected Output: Number of positive numbers: 4 Average value of the said positive numbers: 12.00 Click me to see the solution

29. Write a C program that read 5 numbers and sum of all odd values between them. Test Data : Input the first number: 5 Input the second number: 7 Input the third number: 9 Input the fourth number: 10 Input the fifth number: 13 Expected Output: Sum of all odd values: 34 Click me to see the solution

30. Write a C program to find and print the square of all the even values from 1 to a specified value. Test Data : List of square of each one of the even values from 1 to a 4 : Expected Output: 2^2 = 4 4^2 = 16 Click me to see the solution

31. Write a C program to check whether a given integer is positive even, negative even, positive odd or negative odd. Print even if the number is 0. Test Data : Input an integer: 13 Expected Output: Positive Odd Click me to see the solution

32. Write a C program to print all numbers between 1 and 100 which are divided by a specified number and the remainder will be 3. Test Data : Input an integer: 25 Expected Output: 3 28 53 78 Click me to see the solution

33. Write a C program that accepts some integers from the user and finds the highest value and the input position. Test Data : Input 5 integers: 5 7 15 23 45 Expected Output: Highest value: 45 Position: 5 Click me to see the solution

34. Write a C program to compute the sum of consecutive odd numbers from a given pair of integers. Test Data : Input a pair of numbers (for example 10,2): Input first number of the pair: 10 Input second number of the pair: 2 Expected Output: List of odd numbers: 3 5 7 9 Sum=24 Click me to see the solution

35. Write a C program to check if two numbers in a pair are in ascending order or descending order. Test Data : Input a pair of numbers (for example 10,2 : 2,10): Input first number of the pair: 10 Expected Output: Input second number of the pair: 2 The pair is in descending order! Click me to see the solution

36. Write a C program to read a password until it is valid. For wrong password print "Incorrect password" and for correct password print, "Correct password" and quit the program. The correct password is 1234. Test Data : Input the password: 1234 Expected Output: Correct password Click me to see the solution

37. Write a C program to read the coordinates (x, y) (in the Cartesian system) and find the quadrant to which it belongs (Quadrant -I, Quadrant -II, Quadrant -III, Quadrant -IV). Note: A Cartesian coordinate system is a coordinate system that specifies each point uniquely in a plane by a pair of numerical coordinates. These are often numbered from 1st to 4th and denoted by Roman numerals: I (where the signs of the (x,y) coordinates are I(+,+), II (−,+), III (−,−), and IV (+,−). Test Data : Input the Coordinate(x,y): x: 25 y: 15 Expected Output: Quadrant-I(+,+) Click me to see the solution

38. Write a program that reads two numbers and divides the first number by the second number. If division is not possible print "Division is not possible". Test Data : Input two numbers: x: 25 y: 5 Expected Output: 5.0 Click me to see the solution

39. Write a C program to calculate the sum of all numbers not divisible by 17 between two given integer numbers. Test Data : Input the first integer: 50 Input the second integer: 99 Expected Output: Sum: 3521 Click me to see the solution

40. Write a C program that finds all integer numbers that divide by 7 and have a remainder of 2 or 3 between two given integers. Test Data : Input the first integer: 25 Input the second integer: 45 Expected Output: 30 31 37 38 44 Click me to see the solution

41. Write a C program to print 3 numbers on a line, starting with 1 and printing n lines. Accept the number of lines (n, integer) from the user. Test Data : Input number of lines: 5 Expected Output: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Click me to see the solution

42. Write a C program to print a number, its square and cube, starting with 1 and printing n lines. Accept the number of lines (n, integer) from the user. Test Data : Input number of lines: 5 Expected Output: 1 1 1 2 4 8 3 9 27 4 16 64 5 25 125 Click me to see the solution

43. Write a C program that reads two integers p and q, prints p number of lines in a sequence of 1 to b in a line. Test Data : Input number of lines: 5 Number of characters in a line: 6 Expected Output: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Click me to see the solution

44. Write a C program to calculate the average mathematics marks of some students. Input 0 (excluding to calculate the average) or a negative value to terminate the input process. Test Data : Input Mathematics marks (0 to terminate): 10 15 20 25 0 Expected Output: Average marks in Mathematics: 17.50 Click me to see the solution

45. Write a C program to calculate the value of S where S = 1 + 1/2 + 1/3 + … + 1/50. Expected Output: Value of S: 4.50 Click me to see the solution

46. Write a C program to calculate the value of S where S = 1 + 3/2 + 5/4 + 7/8. Expected Output: Value of series: 4.62 Click me to see the solution

47. Write a C program that finds all the divisors of an integer. Test Data: Input an integer: 45 Expected Output: All the divisor of 45 are: 1 3 5 9 15 45 Click me to see the solution

48. Write a C program that reads and prints the elements of an array of length 7. Before printing, replace every negative number, zero, with 100. Test Data: Input the 5 members of the array: 25 45 35 65 15 Expected Output: Array values are: n[0] = 25 n[1] = 45 n[2] = 35 n[3] = 65 n[4] = 15 Click me to see the solution

49. Write a C program to read and print the elements of an array with length 7. Before printing, insert the triple of the previous position, starting from the second position. For example, if the first number is 2, the array numbers must be 2, 6, 18, 54 and 162 Test Data: Input the first number of the array: 5 Expected Output: n[0] = 5 n[1] = 15 n[2] = 45 n[3] = 135 n[4] = 405 Click me to see the solution

50. Write a C program to read an array of length 5 and print the position and value of the array elements of value less than 5. Test Data: Input the 5 members of the array: 15 25 4 35 40 Expected Output: A[2] = 4.0 Click me to see the solution

51. Write a C program to read an array of length 6, change the first element by the last, the second element by the fifth and the third element by the fourth. Print the elements of the modified array. Test Data: Input the 5 members of the array: 15 20 25 30 35 Expected Output: array_n[0] = 35 array_n[1] = 30 array_n[2] = 25 array_n[3] = 20 array_n[4] = 15 Click me to see the solution

52. Write a C program to read an array of length 6 and find the smallest element and its position. Test Data: Input the length of the array: 5 Input the array elements: 25 35 20 14 45 Expected Output: Smallest Value: 14 Position of the element: 3 Click me to see the solution

53. Write a C program that accepts the principle, rate of interest, and time and calculates simple interest. Test Data: Input Data: p = 10000, r = 10% , t = 12 year Expected Output: Input principle, Rate of interest & time to find simple interest: Simple interest = 12000 Click me to see the solution

54. Write a C program that accepts a distance in centimeters and prints the corresponding value in inches. Test Data: Input Data: 500cms Input the distance in cm: Distance of 500.00 cms is = 196.85 inches Click me to see the solution

55. Write a C program that swaps two numbers without using a third variable. Input value for x & y: Before swapping the value of x & y: 5 7 After swapping the value of x & y: 7 5 Click me to see the solution

56. Write a C program to shift given data by two bits to the left. Input value : 2 Read the integer from keyboard- Integer value = 2 The left shifted data is = 16 Click me to see the solution

57. Write a C program to reverse and print a given number. Input a number: The original number = 234 The reverse of the said number = 432 Click me to see the solution

58. Write a C program that accepts 4 real numbers from the keyboard and prints out the difference between the maximum and minimum values of these four numbers. Input four numbers: 1.54 1.236 1.3625 1.002 Difference is 0.5380 Click me to see the solution

59. Write a C program to display the sum of series 1 + 1/2 + 1/3 + ………. + 1/n. Input any number: 1 + 1/0 Sum = 1/0 Click me to see the solution

60. Write a C program to create enumerated data types for 7 days and display their values in integer constants. Sun = 0 Mon = 1 Tue = 2 Wed = 3 Thu = 4 Fri = 5 Sat = 6 Click me to see the solution

61. Write a C program that accepts a real number x and prints out the corresponding value of sin(1/x) using 4-decimal places. Input value of x: .6235 Value of sin(1/x) is 0.9995 Click me to see the solution

62. Write a C program that accepts a positive integer less than 500 and prints out the sum of the digits of this number. Input a positive number less than 500: Sum of the digits of 347 is 14 Click me to see the solution

63. Write a C program that accepts a positive integer n less than 100 from the user. It prints out the sum of 1 4 + 2 4 + 4 4 + 7 4 + 11 4 + • • • + m 4 . In this case, m is less than or equal to n. Print an appropriate message. Input a positive number less than 100: 68 Sum of the series is 37361622 Click me to see the solution

64. Write a C program that accepts integers from the user until a zero or a negative number, displays the number of positive values, the minimum value, the maximum value, and the average value. Input a positive integer: Input next positive integer: 15 Input next positive integer: 25 Input next positive integer: 37 Input next positive integer: 43 Number of positive values entered is 4 Maximum value entered is 43 Minimum value entered is 15 Average value is 30.0000 Click me to see the solution

65. Write a C program that prints out the prime numbers between 1 and 200. The output should be such that each row contains a maximum of 20 prime numbers. Expected output: The prime numbers between 1 and 199 are: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 Click me to see the solution

66. Write a C program that generates 50 random numbers between -0.5 and 0.5 and writes them to the file rand.dat. The first line of ran.dat contains the number of random numbers, while the next 50 lines contain 50 random numbers. 50 -0.4215 0.2620 0.3065 -0.0485 .... 0.3980 0.1750 0.4780 -0.2915 0.0715 0.3565 Click me to see the solution

67. Write a C program to evaluate the equation y=xn when n is a non-negative integer. Input the values of x and n: 256 x=256.000000; n=0; x to power n=1.000000 Click me to see the solution

68. Write a C program that prints the powers of 2 table for the powers 0 to 10, both positive and negative. ======================================= n 2 to power n 2 to power -n ======================================= 0 1 1.000000000000 1 2 0.500000000000 2 4 0.250000000000 3 8 0.125000000000 4 16 0.062500000000 5 32 0.031250000000 6 64 0.015625000000 7 128 0.007812500000 8 256 0.003906250000 9 512 0.001953125000 10 1024 0.000976562500 ====================================== Click me to see the solution

69. Write a C program to print a binomial coefficient table. Mx 0 1 2 3 4 5 6 7 8 9 10 ---------------------------------------------------------- 0 1 1 1 1 2 1 2 1 3 1 3 3 1 4 1 4 6 4 1 5 1 5 10 10 5 1 6 1 6 15 20 15 6 1 7 1 7 21 35 35 21 7 1 8 1 8 28 56 70 56 28 8 1 9 1 9 36 84 126 126 84 36 9 1 10 1 10 45 120 210 252 210 120 45 10 1 ---------------------------------------------------------- Click me to see the solution

70. Write a C program to print the alphabet set in decimal and character form. [65-A] [66-B] [67-C] [68-D] [69-E] [70-F] [71-G] [72-H] [73-I] [74-J] [75-K] [76-L] [77-M] [78-N] [79-O] [80-P] [81-Q] [82-R] [83-S] [84-T] [85-U] [86-V] [87-W] [88-X] [89-Y] [90-Z] [97-a] [98-b] [99-c] [100-d] [101-e] [102-f] [103-g] [104-h] [105-i] [106-j] [107-k] [108-l] [109-m] [110-n] [111-o] [112-p] [113-q] [114-r] [115-s] [116-t] [117-u] [118-v] [119-w] [120-x] [121-y] [122-z] Click me to see the solution

71. Write a C program to copy a given string into another and count the number of characters copied. Input a string Original string: w3resource Number of characters = 10 Click me to see the solution

72. Write a C program to remove any negative sign in front of a number. Input a value (negative): Original value = -253 Absolute value = 253 Click me to see the solution

73. Write a C program that reads two integers and checks whether the first integer is a multiple of the second integer. Sample Input: 9 3 Sample Output: Input the first integer : Input the second integer: 9 is a multiple of 3. Click me to see the solution

74. Write a C program to display the integer equivalents of letters (a-z, A-Z). Sample Output: List of integer equivalents of letters (a-z, A-Z). ================================================== 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 32 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 Click me to see the solution

75. Write a C program that accepts a seven-digit number, separates the number into its individual digits, and prints the digits separated from one another by two spaces each. Sample Input: 2345678 Input a seven digit number: Output: 2 3 4 5 6 7 8 Click me to see the solution

76. Write a C program to calculate and print the squares and cubes of the numbers from 0 to 20. It uses tabs to display them in a table of values. Sample Output: Number Square Cube ========================= 0 0 0 1 1 1 2 4 8 3 9 27 ..... 18 324 5832 19 361 6859 20 400 8000 Click me to see the solution

77. Write a C program that accepts principal amount, rate of interest and days for a loan and calculates the simple interest for the loan, using the following formula. interest = principal * rate * days / 365. Sample Input: 10000 .1 365 0 Sample Output: Input loan amount (0 to quit): Input interest rate: Input term of the loan in days: The interest amount is $1000.00 Input loan principal_amt (0 to quit): Click me to see the solution

78. Write a C program to demonstrate the difference between predecrementing and postdecrementing using the decrement operator --. Sample Output: Predecrementing: x = 10 x-- = 10 x = 9 Click me to see the solution

79. Write a C program using looping to produce the following table of values. Sample Output: x x+2 x+4 x+6 -------------------------------- 1 3 5 7 4 6 8 10 7 9 11 13 10 12 14 16 13 15 17 19 Click me to see the solution

80. Write a C program that reads the side (side sizes between 1 and 10 ) of a square and prints square using hash (#) character. Sample Input: 10 Sample Output: Input the size of the square: # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Click me to see the solution

81. Write a C program that reads the side (side sizes between 1 and 10 ) of a square and prints a hollow square using the hash (#) character. Sample Input: 10 Sample Output: Input the size of the square: ########## # # # # # # # # # # # # # # # # ########## Click me to see the solution

82. Write a C program that reads a five-digit integer and determines whether or not it's a palindrome. Sample Input: 33333 Sample Output: Input a five-digit number: 33333 is a palindrome. Click me to see the solution

83. Write a C program that reads an integer (7 digits or fewer) and counts the number of 3s in the given number. Sample Input: 538453 Sample Output: Input a number: The number of threes in the said number is 2 Click me to see the solution

84. Write a C program to calculate and print the average of some integers. Accept all the values preceding 888. Sample Input: 12 15 24 888 Sample Output: Input each number on a separate line (888 to exit): The average value of the said numbers is 17.000000 Click me to see the solution

85. Write a C program to print a table of all the Roman numeral equivalents of decimal numbers in the range 1 to 50. Sample Output: Decimal Roman number numeral ------------------- 1 I 2 II 3 III 4 IV ..... 98 LXXXXVIII 99 LXXXXIX 100 C Click me to see the solution

86. Write a C program to display the sizes and ranges for each of C's data types. Sample Output: Size of C data types: Type Bytes -------------------------------- char 1 int8_t 1 unsigned char 1 uint8_t 1 short 2 int16_t 2 uint16t 2 int 4 unsigned 4 long 8 unsigned long 8 int32_t 4 uint32_t 4 long long 8 int64_t 8 unsigned long long 8 uint64_t 8 float 4 double 8 long double 16 _Bool 1 Click me to see the solution

87. Write a C program to display the minimum and maximum values for each of C's data types. Sample Output: Ranges for integer data types in C ------------------------------------------------------------ int8_t -128 127 int16_t -32768 32767 int32_t -2147483648 2147483647 int64_t -9223372036854775808 9223372036854775807 uint8_t 0 255 uint16_t 0 65535 uint32_t 0 4294967295 uint64_t 0 18446744073709551615 ============================================================ Ranges for real number data types in C ------------------------------------------------------------ float 1.175494e-38 3.402823e+38 double 2.225074e-308 1.797693e+308 long double 3.362103e-4932 1.189731e+4932 Click me to see the solution

88. Write a C program to create an extended ASCII table. Print the ASCII values 32 through 255. Sample Output: |---------------------------------------------------------------------------------------------------------| |extended ASCII table - excluding control characters | | Ch Dec Hex | Ch Dec Hex | Ch Dec Hex | Ch Dec Hex | Ch Dec Hex | Ch Dec Hex | Ch Dec Hex | |----------------|----------------|-------------|--------------|--------------|-------------|-------------| | har 32 0x20 | @har 64 0x40 | ` 96 0x60 | � 128 0x80 | � 160 0xa0 | � 192 0xc0 | � 224 0xe0 | | !har 33 0x21 | Ahar 65 0x41 | a 97 0x61 | � 129 0x81 | � 161 0xa1 | � 193 0xc1 | � 225 0xe1 | | "har 34 0x22 | Bhar 66 0x42 | b 98 0x62 | � 130 0x82 | � 162 0xa2 | � 194 0xc2 | � 226 0xe2 | | #har 35 0x23 | Char 67 0x43 | c 99 0x63 | � 131 0x83 | � 163 0xa3 | � 195 0xc3 | � 227 0xe3 | | $har 36 0x24 | Dhar 68 0x44 | d 100 0x64 | � 132 0x84 | � 164 0xa4 | � 196 0xc4 | � 228 0xe4 | | %har 37 0x25 | Ehar 69 0x45 | e 101 0x65 | � 133 0x85 | � 165 0xa5 | � 197 0xc5 | � 229 0xe5 | | &har 38 0x26 | Fhar 70 0x46 | f 102 0x66 | � 134 0x86 | � 166 0xa6 | � 198 0xc6 | � 230 0xe6 | | 'har 39 0x27 | Ghar 71 0x47 | g 103 0x67 | � 135 0x87 | � 167 0xa7 | � 199 0xc7 | � 231 0xe7 | | (har 40 0x28 | Hhar 72 0x48 | h 104 0x68 | � 136 0x88 | � 168 0xa8 | � 200 0xc8 | � 232 0xe8 | | )har 41 0x29 | Ihar 73 0x49 | i 105 0x69 | � 137 0x89 | � 169 0xa9 | � 201 0xc9 | � 233 0xe9 | | *har 42 0x2a | Jhar 74 0x4a | j 106 0x6a | � 138 0x8a | � 170 0xaa | � 202 0xca | � 234 0xea | | +har 43 0x2b | Khar 75 0x4b | k 107 0x6b | � 139 0x8b | � 171 0xab | � 203 0xcb | � 235 0xeb | | ,har 44 0x2c | Lhar 76 0x4c | l 108 0x6c | � 140 0x8c | � 172 0xac | � 204 0xcc | � 236 0xec | | -har 45 0x2d | Mhar 77 0x4d | m 109 0x6d | � 141 0x8d | � 173 0xad | � 205 0xcd | � 237 0xed | | .har 46 0x2e | Nhar 78 0x4e | n 110 0x6e | � 142 0x8e | � 174 0xae | � 206 0xce | � 238 0xee | | /har 47 0x2f | Ohar 79 0x4f | o 111 0x6f | � 143 0x8f | � 175 0xaf | � 207 0xcf | � 239 0xef | | 0har 48 0x30 | Phar 80 0x50 | p 112 0x70 | � 144 0x90 | � 176 0xb0 | � 208 0xd0 | � 240 0xf0 | | 1har 49 0x31 | Qhar 81 0x51 | q 113 0x71 | � 145 0x91 | � 177 0xb1 | � 209 0xd1 | � 241 0xf1 | | 2har 50 0x32 | Rhar 82 0x52 | r 114 0x72 | � 146 0x92 | � 178 0xb2 | � 210 0xd2 | � 242 0xf2 | | 3har 51 0x33 | Shar 83 0x53 | s 115 0x73 | � 147 0x93 | � 179 0xb3 | � 211 0xd3 | � 243 0xf3 | | 4har 52 0x34 | Thar 84 0x54 | t 116 0x74 | � 148 0x94 | � 180 0xb4 | � 212 0xd4 | � 244 0xf4 | | 5har 53 0x35 | Uhar 85 0x55 | u 117 0x75 | � 149 0x95 | � 181 0xb5 | � 213 0xd5 | � 245 0xf5 | | 6har 54 0x36 | Vhar 86 0x56 | v 118 0x76 | � 150 0x96 | � 182 0xb6 | � 214 0xd6 | � 246 0xf6 | | 7har 55 0x37 | Whar 87 0x57 | w 119 0x77 | � 151 0x97 | � 183 0xb7 | � 215 0xd7 | � 247 0xf7 | | 8har 56 0x38 | Xhar 88 0x58 | x 120 0x78 | � 152 0x98 | � 184 0xb8 | � 216 0xd8 | � 248 0xf8 | | 9har 57 0x39 | Yhar 89 0x59 | y 121 0x79 | � 153 0x99 | � 185 0xb9 | � 217 0xd9 | � 249 0xf9 | | :har 58 0x3a | Zhar 90 0x5a | z 122 0x7a | � 154 0x9a | � 186 0xba | � 218 0xda | � 250 0xfa | | ;har 59 0x3b | [har 91 0x5b | { 123 0x7b | � 155 0x9b | � 187 0xbb | � 219 0xdb | � 251 0xfb | | <har 60 0x3c | \har 92 0x5c | | 124 0x7c | � 156 0x9c | � 188 0xbc | � 220 0xdc | � 252 0xfc | | =har 61 0x3d | ]har 93 0x5d | } 125 0x7d | � 157 0x9d | � 189 0xbd | � 221 0xdd | � 253 0xfd | | >har 62 0x3e | ^har 94 0x5e | ~ 126 0x7e | � 158 0x9e | � 190 0xbe | � 222 0xde | � 254 0xfe | | ?har 63 0x3f | _har 95 0x5f |DEL 127 0x7f | � 159 0x9f | � 191 0xbf | � 223 0xdf | � 255 0xff | Click me to see the solution

89. Write a C programming to calculate (x + y + z) for each pair of integers x, y and z where -2^31 <= x, y, z<= 2^31-1. Sample Output: Result: 140733606875472 Click me to see the solution

90. Write a C program to find all prime palindromes in the range of two given numbers x and y (5 <= x<y<= 1000,000,000). A number is called a prime palindrome if the number is both a prime number and a palindrome. Sample Output: Input two numbers (separated by a space): List of prime palindromes: 0 1 Click me to see the solution

91. Write a C program to find the angle between (12:00 to 11:59) the hour hand and the minute hand of a clock. The hour hand and the minute hand are always between 0 and 180 degrees. For example, when it's 12 o'clock, the angle of the two hands is 0 while 3:00 is 45 degrees and 6:00 is 180 degrees. Sample Output: Input hour(h) and minute(m) (separated by a space): 3 0 At 3:00 the angle is 90.0 degrees. Input hour(h) and minute(m) (separated by a space): 6 15 The angle is 90.0 degrees at 6:15. Input hour(h) and minute(m) (separated by a space): 12 0 At 12:00 the angle is 0.0 degrees. Click me to see the solution

92. Write a C program to find the last non-zero digit of the factorial of a given positive integer. For example for 5!, the output will be "2" because 5! = 120, and 2 is the last nonzero digit of 120 Sample Output: Input a positive number: The last non-zero digit of the said factorial: 0 Click me to see the solution

93. Write a C program to check if a given number is nearly prime number or not. Nearly prime numbers are a positive integer which is equal to the product of two prime numbers. Sample Output: It is not a Nearly prime number. Click me to see the solution

94. Write a C program to calculate body mass index and display the grade. Sample Output: Input the weight: 65 Input the height: 5.6 BMI = 2.072704 Grade: Under Click me to see the solution

95. Write a C program to print the corresponding Fahrenheit to Celsius and Celsius to Fahrenheit. Both cases initial tempratue = 0 0 , maximum temperature = 150 0 and step 10 0 Sample Output: Celsius to Fahrenheit --------------------- Celsius Fahrenheit 0.0 32.0 10.0 50.0 20.0 68.0 30.0 86.0 .... 120.0 248.0 130.0 266.0 140.0 284.0 150.0 302.0 Fahrenheit to Celsius --------------------- Fahrenheit Celsius 0.0 -17.8 10.0 -12.2 20.0 -6.7 30.0 -1.1 40.0 4.4 50.0 10.0 ... 120.0 48.9 130.0 54.4 140.0 60.0 150.0 65.6 Click me to see the solution

96. Write a C program to count blanks, tabs, and newlines in input text. Sample Output: Number of blanks, tabs, and newlines: Input few words/tab/newlines The quick brown fox jumps over the lazy dog ^Z blank=7,tab=2,newline=3 Click me to see the solution

97. Write a C program that accepts a string and counts the number of characters, words and lines. Sample Output: Input a string and get number of charcters, words and lines: The quick brown fox jumps over the lazy dog ^Z Number of Characters = 44 Number of words = 9 Number of lines = 1 Click me to see the solution

98. Write a C program that accepts some text from the user and prints each word of that text on a separate line. Sample Output: Input some text: The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog Click me to see the solution

99. Write a C program that takes some integer values from the user and prints a histogram. Sample Output: Input number of histogram bar (Maximum 10): 4 Input the values between 0 and 10 (separated by space): 9 7 4 3 Histogram: ######### ####### #### ### Click me to see the solution

100. Write a C program to convert a currency value (floating point with two decimal places) to the number of coins and notes. Sample Output: Input the currency value (floating point with two decimal places): 10357.75 Currency Notes: 100 number of Note(s): 103 50 number of Note(s): 1 5 number of Note(s): 1 2 number of Note(s): 1 Currency Coins: .50 number of Coin(s): 1 .25 number of Coin(s): 1 Click me to see the solution

101. There are three given ranges. Write a C program that reads a floating-point number and finds the range where it belongs from four given ranges. Sample Output: Input a number: 87 Range (80,100] Click me to see the solution

102. Write a C program that reads three integers and sorts the numbers in ascending order. Print the original numbers and the sorted numbers. Sample Output: Input 3 integers: 17 -5 25 --------------------------- Original numbers: 17, -5, 25 Sorted numbers: -5, 17, 25 Click me to see the solution

103. Write a C program that takes two integers and tests whether they are multiplied or not. In science, a multiple is the product of any quantity and an integer. In other words, for the quantities a and b, we say that b is a multiple of a if b = na for some integer n, which is called the multiplier. If a is not zero, this is equivalent to saying that b/a is an integer. Sample Output: Input two integers: 3 9 Multiplies Click me to see the solution

104. Write a C program that reads the item's price and creates a revised price for the item, based on the item price table. Sample Output: Input the item price:525 New Item price: 582.75 Increased price: 57.75 Increase Percentage: 11% Click me to see the solution

105. Write a C program that accepts seven floating point numbers and counts the number of positive and negative numbers. Print the average of all positive and negative values with two digits after the decimal number. Sample Output: Input 7 numbers(int/float): 25 35.75 15 -3.5 40 35 16 6 Number of positive numbers: Average 27.79 1 Number of negative numbers: Average -3.50 Click me to see the solution

106. Write a C program that accepts 7 integer values and counts the even, odd, positive and negative values. Sample Output: Input 7 integers: 10 12 15 -15 26 35 17 Number of even values: 3 Number of odd values: 4 Number of positive values: 6 Number of negative values: 1 Click me to see the solution

107. Write a C program that prints ten consecutive odd and even numbers after accepting an integer. Sample Output: Input an integer number: 15 Next 10 consecutive odd numbers: 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, Next 10 consecutive even numbers: 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, Click me to see the solution

108. Write a C program that reads two integer values and calculates the sum of all odd numbers between them. Sample Output: Input the first integer number: 25 Input the second integer number (greater than first integer): 45 Sum of all odd values between 25 and 45: 385 Sum of all even values between 25 and 45: 350 Click me to see the solution

109. Write a C program to find and print the square of each even and odd value between 1 and a given number (4 Sample Output: Input a number(integer): 15 Square of each even between 1 and 15: 2^2 = 4 4^2 = 16 6^2 = 36 8^2 = 64 10^2 = 100 12^2 = 144 14^2 = 196 Square of each odd between 1 and 15: 1^2 = 1 3^2 = 9 5^2 = 25 7^2 = 49 9^2 = 81 11^2 = 121 13^2 = 169 15^2 = 225 Click me to see the solution

110. Write a C program to find the odd, even, positive and negative numbers from a given number (integer) and print a message 'Number is positive odd' or 'Number is negative odd' or 'Number is positive even' or 'Number is negative even'. If the number is 0 print "Zero". Sample Output: Input a number (integer): 12 Number is positive-even Click me to see the solution

111. Write a C program that accepts an integer from the user and divides all numbers between 1 and 100. Print those numbers where the remainder value is 3. Sample Output: Input a number (integer): 65 Remainder value is 3 after divide all numbers between 1 and 100 by 65: 3 68 Click me to see the solution

112. Write a C program that reads seven integer values from the user and finds the highest value and its position. Sample Output: Input 6 numbers (integer values): 15 20 25 17 -8 35 Maximum value: 35 Position: 6 Click me to see the solution

113. Write a C program to create and print the sequence of the following example. Sample Output: a=1 b=100 a=6 b=90 a=11 b=80 a=16 b=70 a=21 b=60 a=26 b=50 a=31 b=40 a=36 b=30 a=41 b=20 a=46 b=10 a=51 b=0 Click me to see the solution

Sample Output:

C programming Code Editor:

More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.

Follow us on Facebook and Twitter for latest update.

  • Weekly Trends and Language Statistics

homework c programming

Welcome to the learn-c.org free interactive C tutorial.

Whether you are an experienced programmer or not, this website is intended for everyone who wishes to learn the C programming language.

There is no need to download anything - Just click on the chapter you wish to begin from, and follow the instructions. Good luck!

learn-c.org is still under construction - If you wish to contribute tutorials, please click on Contributing Tutorials down below.

Learn the Basics

  • Hello, World!
  • Variables and Types
  • Multidimensional Arrays
  • While loops
  • Function arguments by reference
  • Dynamic allocation
  • Arrays and Pointers
  • Linked lists
  • Binary trees
  • Pointer Arithmetics
  • Function Pointers

Contributing Tutorials

Read more here: Contributing Tutorials

homework c programming

Coding for Kids is an online interactive tutorial that teaches your kids how to code while playing!

Receive a 50% discount code by using the promo code:

Start now and play the first chapter for free, without signing up.

homework c programming

"Hello World!" in C Easy C (Basic) Max Score: 5 Success Rate: 85.69%

Playing with characters easy c (basic) max score: 5 success rate: 84.45%, sum and difference of two numbers easy c (basic) max score: 5 success rate: 94.64%, functions in c easy c (basic) max score: 10 success rate: 96.03%, pointers in c easy c (basic) max score: 10 success rate: 96.61%, conditional statements in c easy c (basic) max score: 10 success rate: 96.94%, for loop in c easy c (basic) max score: 10 success rate: 93.79%, sum of digits of a five digit number easy c (basic) max score: 15 success rate: 98.66%, bitwise operators easy c (basic) max score: 15 success rate: 95.00%, printing pattern using loops medium c (basic) max score: 30 success rate: 95.96%, cookie support is required to access hackerrank.

Seems like cookies are disabled on this browser, please enable them to open this website

Learn about the C programming language in this beginner-friendly skill path.

Includes C , C Basics , C Control Flow , and more.

  • AI assistance for guided coding help
  • Projects to apply new skills
  • Quizzes to test your knowledge
  • A certificate of completion

homework c programming

Skill level

Time to complete

Prerequisites

About this skill path

The C programming language was first released in 1972, making it one of the oldest still used today. All modern operating systems are implemented with C code, which means that the C language powers almost every technological experience we have. Python’s interpreter is also written in C. Get started learning C fundamentals to become a better programmer in any field of computer science.

Skills you'll gain

  • Learn key programming concepts
  • Write your own C programs
  • Use pointers to work with memory
  • Create custom functions and structures

Welcome to the Learn C Skill Path

Welcome to the Learn C Skill Path!

Get started with the C language and learn about variables and operators.

C Control Flow

Learn about various types of conditionals, loops, and errors in C.

Going Further with C

Learn about arrays, char arrays (or strings), pointers, and memory management in C.

Functions and Structures in C

Learn about functions and structures in C and build and manipulate ones of your own.

Learn C Next Steps

What comes next?

Certificate of completion available with Plus or Pro

The platform

Hands-on learning

An AI-generated hint within the instructions of a Codecademy project

Projects in this skill path

Grocery store, grocery store part 2, dates and switches, earn a certificate of completion.

  • Show proof Receive a certificate that demonstrates you've completed a course or path.
  • Build a collection The more courses and paths you complete, the more certificates you collect.
  • Share with your network Easily add certificates of completion to your LinkedIn profile to share your accomplishments.

homework c programming

Reviews from learners

Our learners work at.

  • Google Logo
  • Amazon Logo
  • Microsoft Logo
  • Reddit Logo
  • Spotify Logo
  • YouTube Logo
  • Instagram Logo

Skill paths help you level-up

Get a specialized skill, get step-by-step guidance, get there quickly, ready to learn a new skill, looking for something else, related resources, why data structures, errors in c++, memory allocation, related courses and paths, learn c: conditionals and loops, learn c: variables and operators, browse more topics.

  • Computer Science 5,446,744 learners enrolled
  • C 163,509 learners enrolled
  • Code Foundations 7,001,867 learners enrolled
  • Web Development 4,677,235 learners enrolled
  • Data Science 4,195,116 learners enrolled
  • Python 3,391,657 learners enrolled
  • For Business 3,054,624 learners enrolled
  • JavaScript 2,737,139 learners enrolled
  • HTML & CSS 2,206,134 learners enrolled

Two people in conversation while learning to code with Codecademy on their laptops

What's included in skill paths

Practice projects, assessments, certificate of completion.

Learn C practically and Get Certified .

Popular Tutorials

Popular examples, reference materials, learn c interactively, learn c programming.

C is one of the foundational programming languages used in the development of compilers, operating systems, and embedded systems where speed and efficiency matter.

It is considered the best language to start because it provides a strong understanding of fundamental coding concepts like data types, variables, loops, and functions.

With a competitive base salary, there is a significant demand for C developers in high-stake fields where high performance is essential.

In this guide, we will cover:

Beginner's Guide to C

Is c for you, best way to learn c, how to run c.

If you are simply looking to learn C step-by-step, you can follow our free tutorials in the next section.

These tutorials will provide you with a solid foundation in C and prepare you for the next step in your career.

Getting Started with C

Your First C Program

C Variables, Constants and Literals

C Data Types

C Input Output (I/O)

C Programming Operators

C if...else Statement

C while and do...while Loop

C break and continue

C switch Statement

C goto Statement

C Functions

C User-defined functions

Types of User-defined Functions in C Programming

C Recursion

C Storage Class

C Multidimensional Arrays

Pass arrays to a function in C

Relationship Between Arrays and Pointers

C Pass Addresses and Pointers

C Dynamic Memory Allocation

C Array and Pointer Examples

C Programming Strings

String Manipulations In C Programming Using Library Functions

String Examples in C Programming

C structs and Pointers

C Structure and Function

C File Handling

C Files Examples

C Keywords and Identifiers

C Precedence And Associativity Of Operators

C Bitwise Operators

C Preprocessor and Macros

C Standard Library Functions

Whether C is the right choice depends on what you want to accomplish and your career goals.

C from a Learning Perspective

If you are new to coding, learning C can help you build a strong programming foundation. However, when we compare the code of C with other modern languages like Python, C might seem a bit complex.

For example, the following programs perform the addition of two numbers in both C and Python.

As you can see, C code includes a lot of syntaxes to perform the same task.

That being said, programming languages like C++, Python, and Java are based on C, so it's relatively easier to switch to these languages once you have a good grasp of C.

You typically learn multiple languages throughout your career, so it's beneficial to have a thorough understanding of how everything works right from the start.

C as Career Choice

C is mainly used in high-performance modern applications like:

  • Embedded Systems Design
  • Operating Systems Development
  • Firmware Development
  • Kernel Design

Learning C offers significant benefits for your career opportunities if you are interested in building complex systems with high performance.

However, there are certain fields where choosing C might not be your best option. For example, if you are interested in web development, data science, machine learning, or mobile development, then C might not be the right answer.

In these cases, alternatives such as JavaScript for web development, Python for data science and machine learning, and Kotlin, Swift, or Java for mobile app development will be more suitable.

Ultimately, your career choice is important in deciding whether C is right for you.

There is no right or wrong way to learn C. It all depends on your learning style and pace.

In this section, we have included the best C learning resources tailored to your learning preferences, be it text-based, video-based, or interactive courses.

Text-based Tutorial

Best: if you are committed to learning C but do not want to spend on it

If you want to learn C for free with a well-organized, step-by-step tutorial, you can use our free C tutorials .

Our tutorials will guide you through C programming one step at a time, using practical examples to strengthen your foundation.

Interactive Course

Best: if you want hands-on learning, get your progress tracked, and maintain a learning streak

Learning to code is tough. It requires dedication and consistency, and you need to write tons of code yourself.

While videos and tutorials provide you with a step-by-step guide, they lack hands-on experience and structure.

Recognizing all these challenges, Programiz offers a premium Learn C Course that allows you to gain hands-on learning experience by solving challenges, building real-world projects, and tracking your progress.

Remember, there is no easy shortcut to learning coding!

Online Video

Best: if you are an audio-visual learner and learn by watching others code and following along

If you're more of a visual learner, we have created a C programming playlist for beginners that will guide you on your journey to C programming.

Additionally, you can also follow the C course from Freecodecamp .

Best: if you are a casual and hobby learner who wants to just get to know C

While it's possible to learn C from mobile apps, it's not the ideal way because writing code can be challenging. Additionally, it's difficult to build real-world projects with multiple files on mobile devices.

Nevertheless, you can use these apps to try things out.

Important: You cannot learn to code without developing the habit of writing code yourself. Therefore, whatever method you choose, always write code.

While writing code, you will encounter errors. Don't worry about them, try to understand them and find solutions. Remember, programming is all about solving problems, and errors are part of the process.

1. Run C in your browser.

We have created an online editor to run C directly on your browser. You don't have to go through a tedious installation process. It's completely free, and you can start coding directly.

how-to-install-c

2. Install C on Your computer.

Once you start writing complex programs and creating projects, you should definitely install C on your computer. It's needed especially when you are creating projects with multiple files and folders.

To install C on your device, you can use this guide.

how-to-install-c-2

Learn how you can install and use C on your own computer.

Codeforwin

C programming examples, exercises and solutions for beginners

Fundamentals.

  • Hello world program in C
  • Basic input/output
  • Basic IO on all data types
  • Perform arithmetic operations
  • Find area and perimeter of rectangle
  • Find diameter and area of circle
  • Find area of triangle
  • Find angles of triangle
  • Temperature conversion
  • Length conversion
  • Days conversion
  • Find power of a number
  • Find square root
  • Calculate simple interest
  • Calculate compound interest
  • Find range of data types

Bitwise Operator

  • Check Least Significant Bit (LSB)
  • Check Most Significant Bit (MSB)
  • Get nth bit of a number
  • Set nth bit of a number
  • Clear nth bit of a number
  • Toggle nth bit of a number
  • Highest set bit of a number
  • Lowest set bit of a number
  • Count trailing zeros of binary number
  • Count leading zeros of binary number
  • Flip bits of a number
  • Rotate bits of a number
  • Decimal to binary
  • Swap two numbers
  • Check even or odd
  • View all Bitwise operator examples →

Ternary Operator

  • Maximum of two numbers
  • Maximum of three numbers
  • Check leap year
  • Check alphabet
  • View all ternary operator examples →
  • Find maximum of two numbers
  • Find maximum of three numbers
  • Check negative, positive or zero
  • Check divisibility
  • Check alphabet character
  • Check vowel or consonant
  • Check alphabet, digit or special character
  • Check uppercase or lowercase
  • Print day of week
  • Find number of days in month
  • Find roots of quadratic equation
  • Calculate profile/loss
  • View all if else examples →

Switch case

  • Find total days in month
  • Check positive, negative or zero
  • Simple calculator application
  • View all switch case examples →

Loop/Iteration

  • Print natural numbers from 1 to n
  • Print alphabets from a to z
  • Print even numbers from 1 to n
  • Print sum of all numbers from 1 to n
  • Print sum of all odd numbers from 1 to n
  • Print multiplication table of n
  • Find number of digits in a number
  • Find first and last digit
  • Find sum of first and last digit
  • Swap first and last digit
  • Find sum of digits of a number
  • Find reverse of a number
  • Find frequency of digits in a number
  • Find power of a number using loop
  • Find factorial of a number
  • Find HCF of two numbers
  • Find LCM of two numbers
  • View all loop examples →

Number system and conversion

  • Find one's complement
  • Find two's complement
  • Binary to octal conversion
  • Binary to decimal conversion
  • Binary to hexadecimal conversion
  • Octal to binary conversion
  • Octal to decimal conversion
  • Octal to hexadecimal conversion
  • Decimal to binary conversion
  • Decimal to octal conversion
  • Decimal to hexadecimal conversion
  • Hexadecimal to binary conversion
  • Hexadecimal to octal conversion
  • Hexadecimal to decimal conversion
  • View all conversion examples →

Star patterns

  • Pascal triangle generation
  • Square star pattern
  • Hollow square star pattern
  • Hollow square star pattern with diagonal
  • Rhombus star pattern
  • Hollow rhombus star pattern
  • Right triangle star pattern
  • Hollow right triangle star pattern
  • Inverted right triangle star pattern
  • Mirrored inverted right triangle star pattern
  • Pyramid star pattern
  • Inverted pyramid star pattern
  • Diamond star pattern
  • Plus starpattern
  • X star pattern
  • 8 star pattern
  • Heart star with name pattern
  • View all star pattern examples →

Number patterns

  • Square number pattern
  • Right triangle number pattern
  • Inverted right triangle
  • Triangle with zero filled
  • Half diamond pattern
  • Half diamond star bordered pattern
  • X number pattern
  • View all number pattern examples →
  • Find cube using functions
  • Diameter & area of circle using functions
  • Maximum and minimum using functions
  • Check even odd using functions
  • Check Prime number using functions
  • Find all prime numbers using functions
  • Find all strong numbers using functions
  • Find all armstrong numbers using functions
  • Find all perfect numbers using functions
  • View all function examples →
  • Find power using recursion
  • Print natural numbers using recursion
  • Print even numbers using recursion
  • Sum of natural numbers using recursion
  • Sum of even/odd numbers using recursion
  • Find reverse using recursion
  • Check palindrome using recursion
  • Find sum of digits using recursion
  • Find factorial using recursion
  • Generate nth Fibonacci term using recursion
  • Find HCF (GCD) using recursion
  • Find LCM using recursion
  • Sum of array elements using recursion
  • View all recursion examples →
  • Input and display array elements
  • Sum of all array elements
  • Find second largest element in array
  • Copy one array to another
  • Insert new element in array
  • Delete an element from array
  • Find frequency of array elements
  • Merge two array to third array
  • Delete duplicate elements from array
  • Reverse an array
  • Search an element in array
  • Sort an array
  • Left rotate an array
  • Right rotate an array
  • View all array examples →

Matrix (2D array)

  • Add two matrices
  • Scalar matrix multiplication
  • Multiply two matrices
  • Check if two matrices are equal
  • Sum of diagonal elements of matrix
  • Interchange diagonal of matrix
  • Find upper triangular matrix
  • Find sum of lower triangular matrix
  • Find transpose of triangular matrix
  • Find determinant of a matrix
  • Check identity matrix
  • Check sparse matrix
  • Check symmetric matrix
  • View all matrix examples →
  • Find length of string
  • Copy string to another string
  • Concatenate two strings
  • Compare two strings
  • Convert lowercase to uppercase
  • Find reverse of a string
  • Check palindrome
  • Reverse order of words
  • Search a character in string
  • Search a word in string
  • Find highest occurring character
  • Remove all duplicate characters
  • Replace a character in string
  • Trim whitespace from string
  • View all string examples →
  • Create, initialize and use pointer
  • Add two numbers using pointers
  • Swap two numbers using pointers
  • Access array using pointers
  • Copy array using pointers
  • Reverse array using pointers
  • Access 2D array using pointers
  • Multiply matrices using pointers
  • Copy strings using pointers
  • Concatenate strings using pointers
  • Compare strings using pointers
  • Reverse strings using pointers
  • Sort array strings using pointers
  • Return multiple values from function using pointers
  • View all pointers examples →
  • Create file and write contents
  • Read file contents and display
  • Append contents to file
  • Compare two files
  • Copy one file to another
  • Merge two files
  • Remove a word from file
  • Remove a line from file
  • Replace a word in file
  • Replace a line in file
  • Print source code
  • Convert uppercase to lowercase in file
  • Find properties of file
  • Check if file or directory exists
  • Rename a file or directory
  • List of files recursively
  • View all files handling examples →

Macros/Pre-processor directives

  • Create custom header file
  • Define, undefine and redefine a macro
  • Find sum using macro
  • Find square and cube using macro
  • Check even/odd using macro
  • Find maximum or minimum using macro
  • Check lowercase/uppercase using macro
  • Swap two numbers using macro
  • Multiline macros

Get the Reddit app

R/cprogramming.

By continuing, you agree to our User Agreement and acknowledge that you understand the Privacy Policy .

Enter the 6-digit code from your authenticator app

You’ve set up two-factor authentication for this account.

Enter a 6-digit backup code

Create your username and password.

Reddit is anonymous, so your username is what you’ll go by here. Choose wisely—because once you get a name, you can’t change it.

Reset your password

Enter your email address or username and we’ll send you a link to reset your password

Check your inbox

An email with a link to reset your password was sent to the email address associated with your account

Choose a Reddit account to continue

Browse Course Material

Course info, instructors.

  • Daniel Weller
  • Sharat Chikkerur

Departments

  • Electrical Engineering and Computer Science

As Taught In

  • Programming Languages
  • Software Design and Engineering

Learning Resource Types

Practical programming in c, problem set 1.

Problem set on writing, compiling, and debugging C programs, preprocessor macros, the C file structure, variables, functions and program statements, and returning from functions.

facebook

You are leaving MIT OpenCourseWare

CS2022: Introduction to C

Announcements.

This course provides a brief introduction to the C programming language and standard libraries for students with programming experience at the CS1110 level. We will cover basic syntax, programming paradigm, standard libraries, and debugging for C on the GNU/Linux platform.

Organization

Mondays: 12:20-13:10 (245 Olin Hall)
Wednesdays: 12:20-13:10 (245 Olin Hall)
8:00-8:50 ( Upson Hall)
  • Instructor : Hussam Abu-Libdeh [first name @cs.cornell.edu]
  • Wednesdays 11:10am - 12:10pm
  • Location: 4139 Upson Hall

Assignments & Grading

The homework assignments will be released and submitted through the Course Management System .

As this is a S/U course, to complete it successfully you need a "pass" on all of the homework assignment s on C programming .  This course follows the Cornell University Code of Academic Integrity . Each student in this course is expected to abide by the Cornell University Code of Academic Integrity. You should not discuss solutions to the assignment s with your classmates.  This not only implies that you should have written them but also that you should understand them! You are free to consult books and online resources, but you will have to properly cite them. If there is enough interest, a more elaborate "final" project might be an option for completing the class, provided that it covers all features in the homeworks.

Development Environment

The class will use Linux as an environment for development and testing. Programs will be compiled with gcc and debugging will be done with gdb . You can do the homeworks on other platforms, but testing will be done on Linux and thus it is recommended to try to use Linux.

  • Solutions: fact1.c ,  fact2.c ,  zipper.c
  • Solutions: charfreq.c
  • Solutions: iManip.c

Syllabus and Lecture Slides

  • General Introduction
  • examples shown in class: Hello World ,  Variables ,  Functions ,  Conditionals ,  Command Line Arguments , 
  • examples shown in class: Swapping values with pointers and without
  • examples shown in class: Bad stack usage .  Good heap usage
  • Arrays & Strings
  • examples shown in class: Enums ,  Structs ,  Unions ,  Function pointers ,  typedef .
  • Helpful slides from my Unix course: Moving around the filesystem , and A very quick taste of Vim . (Note: both slide sets contain more info than was covered in class, use them only as reference)
  • examples used in class: Pointers vs Arrays ,  Tracing using fprintf ,  stderr vs stdout  (compile this program, and then redirect its output to a file to see the effect. Example, ./stderr > output.txt ),  Stepping through a program that throughs a segmentation fault
  • class examples:  Terminal IO (keyboard) ,  File IO (requires a text file called file.txt in its directory),  Network Server ,  Network Client (run the server first then the client).
  • #include : include.c ,  minmax.h ,  minmax.c Compile with gcc include.c minmax.c
  • #define : define.c
  • #ifdef : ifdef.c ,  mylib.h ,  mylib.c Compile with gcc -DDEBUG ifdef.c mylib.c to use the custom malloc and free. Compile without the -DDEBUG option and you will use the default malloc and free. Alternatively, you can just add a #define DEBUG at the beginning of ifdef.c to use the custom functions.
  • class examples: exercise.c ,  iteration1.c ,  iteration2.c
  • threads.c : compile with gcc -pthread
  • counters.c : compile with gcc -pthread . This code is meant to demonstrate synchronization issues across threads. Consider taking the Operating Systems course (CS 4410) to learn more about this subject.
  • Goto, Exceptions, and Assembly in C
  • Course Recap

C Functions

C structures, c reference.

C is a general-purpose programming language that has been widely used for over 50 years.

C is very powerful; it has been used to develop operating systems, databases, applications, etc.

Examples in Each Chapter

Our "Try it Yourself" editor makes it easy to learn C. You can edit code and view the result in your browser:

Click on the "Try it Yourself" button to see how it works.

We recommend reading this tutorial, in the sequence listed in the left menu.

C Exercises

Test yourself with exercises.

Insert the missing part of the code below to output "Hello World!".

Start the Exercise

Advertisement

Learn by taking a quiz! The quiz will give you a signal of how much you know about C.

Start C Quiz

My Learning

Track your progress with the free "My Learning" program here at W3Schools.

Log in to your account, and start earning points!

This is an optional feature. You can study at W3Schools without using My Learning.

Track your progress with at W3Schools.com

Learn by Examples

Learn by examples! This tutorial supplements all explanations with clarifying examples.

See All C Examples

Get Certified

COLOR PICKER

colorpicker

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail: [email protected]

Top Tutorials

Top references, top examples, get certified.

  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
  • OverflowAI GenAI features for Teams
  • OverflowAPI Train & fine-tune LLMs
  • Labs The future of collective knowledge sharing
  • About the company Visit the blog

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

Homework: C Programming - Structures and Arrays

My assignment requires the use of the following linked list structure:

My problem is, the arrays for programs, labs and exams are being loaded from a file and are to be variable lengths.

I tried using a pointer to the array, however whenever I updated the array for a new student it would replace the scores for everyone in the linked list.

I've tried going over this with the instructor and he tells me to google it. :(

So far, I haven't had any luck and it's beyond the scope of what our book covers.

Any help would be appreciated.

Andrew's user avatar

  • Show us some code you've already written. –  abelenky Commented Mar 6, 2011 at 19:10
  • Was having trouble with the display, it's up now. –  Andrew Commented Mar 6, 2011 at 19:11
  • When you say whenever I updated the array , what do you mean exactly? –  sashoalm Commented Mar 6, 2011 at 19:14
  • I create the array int scores[] = {90, 95, 100} and then update the array scores[0]=80... Per the answer below I think I need to allocate new memory for it. –  Andrew Commented Mar 6, 2011 at 19:20

4 Answers 4

From what you describe:

You need to create a new object for each item in the array.

so first you create something to hold the first item (like a pointer to the first item). Then as you load each item, create new studentNode and then add it to the array.

Preet Sangha's user avatar

Make sure each studentNode isn't sharing the same programs , labs , etc arrays. In addition to creating the studentNode , you have to create the arrays within them.

dappawit's user avatar

I believe your question is referring to how to specify the size of the programs, labs, and exams arrays.

Instead of storing the array in your struc, keep a pointer to your array. Then, after you have built your program array outside of your structure (using malloc if necessary) reassign your node.program pointer to that array.

amccormack's user avatar

It sounds like you are using the same array for all students. You need to allocate a separate array for each student.

You can either statically allocate a fixed number of elements in a 2d array:

In this case you will need to point each studentNodes array to the correct array(for each student).

Or allocate some memory on the heap for each student.

user623879's user avatar

  • I believe the instructor wants us to allocate additional memory. I'll try your second suggestion. –  Andrew Commented Mar 6, 2011 at 19:17
  • don't cast the return value of malloc in C. it's unnecessary and it can silence compiler warnings which you might want to see. (the exception is in polyglot C/C++ code, where the cast is required.) –  Philip Potter Commented Mar 6, 2011 at 19:54

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged c arrays structure or ask your own question .

  • The Overflow Blog
  • Unpacking the 2024 Developer Survey results
  • Featured on Meta
  • We've made changes to our Terms of Service & Privacy Policy - July 2024
  • Introducing an accessibility dashboard and some upcoming changes to display...
  • Tag hover experiment wrap-up and next steps

Hot Network Questions

  • Iterative mixing problem
  • Polynomial isoperimetric inequalities for finitely presented subdirect products of limit groups
  • dealing with the feeling after rejection
  • Approximating a partition
  • Why is the completely dark disk of the Moon visible on a new moon if the lunar orbit is at an angle to the Earth’s?
  • Can a train/elevator be feasible for scaling huge mountains (modern technology)?
  • How bright would nights be if the moon were terraformed?
  • High-precision solution for the area of a region
  • When is the action of a mapping class group on the set of punctures realized by a finite subgroup of mapping classes?
  • Statistically, which is more of a severe penalty on a d20 roll, Disadvantage or a -10 penalty?
  • Generalized Super-Luhn
  • "Continuity" in a metric space
  • In Europe, are you allowed to enter an intersection on red light in order to allow emergency vehicles to pass?
  • What happens if your child sells your car?
  • What type of concept is "mad scientist"?
  • Mathematical Theory of Monotone Transforms
  • What are these red pointy flower buds with heart-shaped leaves?
  • In Norway, when number ranges are listed 3 times on a sign, what do they mean?
  • Mobility of salts on unbonded bare silica HILIC column
  • How to use Mathematica to plot following helix solid geometry?
  • Wall of Fire: Taking damage multiple times by using forced movement on a target
  • Why do commercial airliners go around on hard touchdown?
  • When can a citizen's arrest of an Interpol fugitive be legal in Washington D.C.?
  • How to get this fencing wire at a [somewhat] equal tension

homework c programming

IMAGES

  1. C Programming Assignment Help

    homework c programming

  2. Get Expert Help with C Programming Homework

    homework c programming

  3. |Homework 10| Intermediate C++ Game Programming

    homework c programming

  4. GitHub

    homework c programming

  5. C programming homework help. Programming Homework Help

    homework c programming

  6. [C#] Intro Programming Homework

    homework c programming

COMMENTS

  1. C Exercises

    SYSTEM & C PROGRAMMING | Sec B AKTU 1st Year Sem 1 Solved Paper 2017-18 | COMP. SYSTEM & C PROGR. 3 min read. Working of Keyword long in C programming. In C, long is a keyword that symbolizes the Long datatype. The long data type is a 64-bit two's complement integer with: Size: 64 bit Value: -263 to 263-1 The output of 64 bit GCC compiler would ...

  2. C Examples

    Program. C Program to Print an Integer (Entered by the User) C Program to Add Two Integers. C Program to Multiply Two Floating-Point Numbers. C Program to Find ASCII Value of a Character. C Program to Compute Quotient and Remainder. C Program to Find the Size of int, float, double and char. C Program to Demonstrate the Working of Keyword long.

  3. C programming Exercises, Practice, Solution

    C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. C was originally developed by Dennis Ritchie between 1969 and 1973 at Bell Labs.

  4. C Exercises

    You can test your C skills with W3Schools' Exercises. Exercises. We have gathered a variety of C exercises (with answers) for each C Chapter. Try to solve an exercise by editing some code, or show the answer to see what you've done wrong. Count Your Score. You will get 1 point for each correct answer. Your score and total score will always be ...

  5. C Programming basic

    4. Write a C program to print the following characters in reverse. Test Characters: 'X', 'M', 'L'. Expected Output: The reverse of XML is LMX. Click me to see the solution. 5. Write a C program to compute the perimeter and area of a rectangle with a height of 7 inches and width of 5 inches. Expected Output:

  6. Practice C

    Improve your C programming skills with over 200 coding practice problems. Solve these beginner friendly problems online to get better at C language. 4.5 (3406 reviews) 223 Problems Beginner level. 42.1k Learners. Start My Journey. Please login to see the progress. Problems. 1.

  7. Learn C

    Welcome. Welcome to the learn-c.org free interactive C tutorial. Whether you are an experienced programmer or not, this website is intended for everyone who wishes to learn the C programming language. There is no need to download anything - Just click on the chapter you wish to begin from, and follow the instructions. Good luck!

  8. Solve C

    Join over 23 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews. We use cookies to ensure you have the best browsing experience on our website. ... For Loop in C. Easy C (Basic) Max Score: 10 Success Rate: 93.78%. Solve Challenge. Sum of Digits of a Five Digit Number. Easy C ...

  9. Learn C

    The C programming language was first released in 1972, making it one of the oldest still used today. All modern operating systems are implemented with C code, which means that the C language powers almost every technological experience we have. Python's interpreter is also written in C. Get started learning C fundamentals to become a better ...

  10. C Programming

    C Challenges [35 exercises with solution] [An editor is available at the bottom of the page to write and execute the scripts.Go to the editor]. 1. Write a C program to get the indices of two numbers in a given array of integers. This will enable you to get the sum of two numbers equal to a specific target.

  11. Learn C Programming

    Learn C Programming. C is one of the foundational programming languages used in the development of compilers, operating systems, and embedded systems where speed and efficiency matter. It is considered the best language to start because it provides a strong understanding of fundamental coding concepts like data types, variables, loops, and ...

  12. C programming examples, exercises and solutions for beginners

    Matrix (2D array) Add two matrices. Scalar matrix multiplication. Multiply two matrices. Check if two matrices are equal. Sum of diagonal elements of matrix. Interchange diagonal of matrix. Find upper triangular matrix. Find sum of lower triangular matrix.

  13. Homework

    A. You are a teacher, and you teach 5 different classes. Each class has a different number of students (e.g., 5, 8, 4, 7 and 5), which you store in a one-dimensional array of integers.You store the midterm exam scores (65, 99, 86, etc.) for each student in each class in a 2-dimensional array of integers.Write a program to calculate the average score for each class, storing them into an array ...

  14. Assignments

    (This ZIP file contains: 1 .txt file and 2 .c files.) 4 Pointers, arrays, strings, searching and sorting algorithms 5 Linked lists, trees 6a Pointers to pointers, multidimensional arrays, stacks and queues (This ZIP file contains: 1 .txt file and 2 .c files.) 6b Function pointers, hash table

  15. Old School C Programming Subreddit

    C is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, with a static type system. By design, C provides constructs that map efficiently to typical machine instructions.

  16. Problem Set 1

    Problem set on writing, compiling, and debugging C programs, preprocessor macros, the C file structure, variables, functions and program statements, and returning from functions. ... Practical Programming in C. Menu. More Info Syllabus Calendar Lecture Notes Labs Assignments Assignments. Problem Set 1. Description: Problem set on writing ...

  17. C Programming: A Modern Approach

    Now, with expert-verified solutions from C Programming: A Modern Approach 2nd Edition, you'll learn how to solve your toughest homework problems. Our resource for C Programming: A Modern Approach includes answers to chapter exercises, as well as detailed information to walk you through the process step by step. With Expert Solutions for ...

  18. CS 2022

    The homework assignments will be released and submitted through the Course Management System. As this is a S/U course, to complete it successfully you need a "pass" on all of the homework assignment s on C programming. This course follows the Cornell University Code of Academic Integrity. Each student in this course is expected to abide by the ...

  19. C Tutorial

    C is a general-purpose programming language that has been widely used for over 50 years. C is very powerful; it has been used to develop operating systems, databases, applications, etc. Start learning C now ».

  20. Homework-C Programming- Recursive Program

    You need to put the entire function out of the main. You have done f(x) = f(x - 1) + 2;. Here you have a function on the left side of the assignment which is incorrect. Also i could not understant what was the cause of such an attempt. The code which you require to computer the recursive function is:

  21. Homework: C Programming

    You need to allocate a separate array for each student. You can either statically allocate a fixed number of elements in a 2d array: int progs[Num_students][x]; In this case you will need to point each studentNodes array to the correct array(for each student).