triangle[i][i+1]=1;
It's this line isn't it? Thanks, I'll fix that now.
EDIT:
I did it again here.
for(j=1; j<i+1; j++)
Should be corrected in the OP now.
Here is the given problem. I have a question for part c and e.
Calculate and print first 12 rows of the famous Pascal triangle, as shown below. Each number is the sum of the two numbers immediately above it. As our intent is to practice pointers, functions, loops, and dynamic memory...
Sorry, let me clarify a little. Valid input would look something like this:
program.exe John Doe -age 43
or
program.exe -age 56 Jane Doe
or
program.exe Bob Smith
Where program.exe is argument 0 and so on...
Here is the given assignment:
Write a code that would
parse the command line
and display the user’s first /
last name and (if given)
his/her age. The ‘-age’ key,
if present, could be the first
or, alternatively, the third
argument and indicates that
the following parameter is
age, as in the...
Yeah, valid_input was an integer variable. And I think the ! in front of the int is what confused me. I had done it another way but this was how the prof did it in his solution. I was just trying to understand why his way worked also.
I have the following chunk of C code that checks for errors. Works fine but I don't understand why it works.
printf("\nEnter the number of students\n");
valid_input = scanf("%d", &snum);
if(!valid_input){
printf("\nInvalid number of students\n");
system("pause");
return 1;
}
The...
I wasn't able to figure out how to track variables in a debugger. However, the due date was extended so I will sit down this weekend and try to figure it out. Also, I'll have another chance to talk to the prof tomorrow. We've not done anything with pointers so I'm not sure if that's an option...
I need to take the values from a string , such as {23 45 67\0}, and store them into an int array. I need to do this with atoi() and isdigit() but I'm having some issues. Here is what I have.
for(i=0; i<=n; i++){
num[i]=atoi(str);
for(j=0; (isdigit(str[j])!=0); j++){...
Thanks a lot. Took me a bit to get the wrap around to work properly but I got it. I don't think modulo was very intuitive to me before but now I get it.
Use nested for loops to produce the following pattern of cyclic permutations of the English
alphabet:
abcde...yz
bcdef...za
cdef...zab
...
zabcde...xy
HINT: you may find the modulo (remainder) operator % useful.
I have an idea of how to do this but it would not use the modulo operator...
I was reading the other day with the light on behind me. I cast a shadow over the book I was reading and was still able to read it (not that surprising). I'd never thought about this before though. Why is it you can read in a shadow but not the dark? I could understand if there was another...