KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
The exercise says "Create a function with two parameters a and b which are integers and the function will return an array of integers with every number from a to b. #include <stdio.h> #include <stdlib.h> void exc(int a, int b){ int i,k=0,d[k]; for(i=a;i<=b;i++){ d[k]=i; k++; printf("%d ",d[k]); } } int main(void){ int c,d; printf("Give first integer: "); scanf("%d",&c); printf("Give second integer: "); scanf("%d",&d); exc(c,d); system("pause"); } The problem is that if I put for example c=2 and d=5 the program returns something like 2088806975 16384 1 2293536 instead of 2 3 4 5. Where is the problem? Thanks
Tags (comma-separated)
Save Edits
Cancel