# Programmers Discussion

Hello Everyone 🙂 This is the discussion area for you all. If you want to ask any question or want to know about any program. So Feel Free to Ask. I’ll try my best for you all.

Suggestions are also Welcome

Keep Asking and Happy Coding ..

## 6 thoughts on “Programmers Discussion”

1. Programming Exercise-IV
see whether writing a program goes as smoothly as it looks.
1. Write a program that reads a date (day and month) and calculates the day’s number in the
current year.
Use an array to store the number of days in each month (ignore leap years):
int days[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
2. Run the following program and see what happens if an array index goes out of range.
Explain the results.
#include
#define NA 4
#define NB 7
int main (void) {
int b[NB],a[NA];
int index;
for ( index = 0; index < NB; ++index )
b[index]=10+index;
for ( index = 0; index < NA+2; ++index )
a[index]=index;
for ( index = 0; index < NA+2; ++index )
printf ("a[%i] = %i ", index, a[index]);
printf("\n");
for ( index = 0; index < NB; ++index )
printf ("b[%i] = %i ", index, b[index]);
printf("\n");
return 0;
}
3. Write a function that raises an integer to a positive integer power. Call the function
x_to_the_n taking two integer arguments x and n. Have the function return a long int,
which represents the results of calculating x to the power of n.
4. Write a function called arraySum that takes two arguments: an integer array and the
number of elements in the array. Have the function return as its result the sum of the
elements in the array. Write a program that reads n integer values from standard input,
stores them in an array and calls arraySum to calculate their sum.
Programming Exercise-IV
see whether writing a program goes as smoothly as it looks.
5. Write a program that reads a matrix with N rows and M columns and calculates and
displays the sum of the elements from each row, by calling the function arraySum
defined in the previous exercise.
6. Write a function prime that returns 1 if its argument is a prime number and returns 0
otherwise. Write a program that reads a number from standard input and calls the
function prime to test whether it is a prime number or not.
7. Write a function called removeString to remove a specified number of characters from a
character string.The function should take three arguments: the source string, the starting
index number in the source string, and the number of characters to remove. So, if the
character array text contains the string "the wrong son", the call
removeString (text, 4, 6);has the effect of removing the characters “wrong “ (the word
“wrong” plus the space that follows) from the array text.The resulting string
inside text is then "the son". Write a main() that calls this function.
8. Write a program that analyzes a character that is typed in from the terminal and classifies
it as either an alphabetic character (a–z or A–Z), a digit (0–9), or a special character
(anything else).To read a single character from the terminal, the format characters %c are
used in the scanf call.
9. Modify the previous program so that alphabetic characters are distinguished in lowercase
and uppercase. If the character was lowercase, the program prints it in uppercase and if it
was in uppercase, the program prints it in lowercase. If the character was a digit, the
program prints the square of its value.
10. Write a program that takes an integer keyed in from the terminal and extracts and
displays each digit of the integer in English.
So, if the user types in 932, the program should display
nine three two
Remember to display “zero” if the user types in just a 0.

Like

1. Ofcorse Kaif ,, I agree with you and it’s not applicable for C only ,, It’s compulsory for every language to learn it. We must make programs, not only learning the language concepts and principles.

And thanks for the list of programs, two of the programs I din;t made yet. I am going to write them and also then blogging them.

Like

1. brooks decorie says:

Hello, please share the solutions to these questions

Like

2. Sam says: