Click here to Skip to main content
13,625,905 members

ATL / WTL / STL

 
GeneralRe: how to use getchar() to store n names in an array ? Pin
Tarun Jha26-Dec-17 20:02
memberTarun Jha26-Dec-17 20:02 
Questionhow to initialize a value to pointer ? Pin
Tarun Jha21-Dec-17 9:08
memberTarun Jha21-Dec-17 9:08 
AnswerRe: how to initialize a value to pointer ? Pin
Rick York21-Dec-17 9:45
memberRick York21-Dec-17 9:45 
GeneralRe: how to initialize a value to pointer ? Pin
Tarun Jha21-Dec-17 10:20
memberTarun Jha21-Dec-17 10:20 
GeneralRe: how to initialize a value to pointer ? Pin
Rick York21-Dec-17 12:25
memberRick York21-Dec-17 12:25 
GeneralRe: how to initialize a value to pointer ? Pin
Tarun Jha26-Dec-17 8:13
memberTarun Jha26-Dec-17 8:13 
AnswerRe: how to initialize a value to pointer ? Pin
Richard MacCutchan21-Dec-17 21:42
protectorRichard MacCutchan21-Dec-17 21:42 
QuestionProblem with recursion. Pin
Tarun Jha16-Dec-17 5:46
memberTarun Jha16-Dec-17 5:46 
The recursion used in the final_array function not working.
#include <stdio.h>

int final_array(int arr[], int size, int k, int i);
void array(int arr[], int i, int size);

int main()
{
	int num, size[100];
	int i, j, k=0;
	int arr[100][100];

	printf("Enter the number of arrays: \t");
	scanf("%d", &num);
	num = num < 100 ? num: 100;
	//feeding elements.
	for (i = 0; i<num; i++)
	{
		printf("\nEnter the size of the array: \t");
		scanf("%d", &size[i]);

		printf("\nEnter the array: ");
		//int arr[i][size[i+1]];
		size[i] = size[i] < 100 ? size[i] : 100;
		array(&arr[i][0], i, size[i]);
	}

	for(i=0; i<num; i++)
    {
        final_array(&arr[i][0], size[i], k, i);
        printf("\n");
    }

	printf("\nPress Enter key to exit.\n");
	getchar();

	return 0;
}

void array(int arr[], int i, int size)
{
	int j;
	for (j = 0; j<size; j++)
	{
		printf("\nEnter arr[%d][%d]: \t",i, j);
		scanf("%d", &arr[j]);
	}
}

int final_array(int arr[], int size, int k, int i)
{
    if(k<=size)
    {
        printf("%d", arr[k]);
        final_array(&arr[i][0], size[i], k++, i);
    }
    else
        return 0;


    /*
    int j;
    for(j=0; j<size; j++)
    {
    	printf("%d\t", arr[j]);
	}
	*/
}


modified 16-Dec-17 13:25pm.

QuestionRe: Recursion not working. Pin
Richard MacCutchan16-Dec-17 6:24
protectorRichard MacCutchan16-Dec-17 6:24 
AnswerRe: Recursion not working. Pin
Tarun Jha16-Dec-17 7:51
memberTarun Jha16-Dec-17 7:51 
GeneralRe: Recursion not working. Pin
Richard MacCutchan16-Dec-17 9:49
protectorRichard MacCutchan16-Dec-17 9:49 
GeneralRe: Recursion not working. Pin
Rick York21-Dec-17 9:49
memberRick York21-Dec-17 9:49 
QuestionTo take input for n number of arrays and print it. Pin
Tarun Jha10-Dec-17 4:55
memberTarun Jha10-Dec-17 4:55 
AnswerRe: To take input for n number of arrays and print it. Pin
Richard MacCutchan10-Dec-17 5:49
protectorRichard MacCutchan10-Dec-17 5:49 
GeneralRe: To take input for n number of arrays and print it. Pin
Tarun Jha10-Dec-17 6:11
memberTarun Jha10-Dec-17 6:11 
GeneralRe: To take input for n number of arrays and print it. Pin
Richard MacCutchan10-Dec-17 6:18
protectorRichard MacCutchan10-Dec-17 6:18 
GeneralRe: To take input for n number of arrays and print it. Pin
Tarun Jha10-Dec-17 6:48
memberTarun Jha10-Dec-17 6:48 
GeneralRe: To take input for n number of arrays and print it. Pin
Richard MacCutchan10-Dec-17 6:52
protectorRichard MacCutchan10-Dec-17 6:52 
GeneralRe: To take input for n number of arrays and print it. Pin
Tarun Jha10-Dec-17 7:19
memberTarun Jha10-Dec-17 7:19 
AnswerRe: To take input for n number of arrays and print it. Pin
Member 1332249811-Dec-17 8:55
memberMember 1332249811-Dec-17 8:55 
GeneralRe: To take input for n number of arrays and print it. Pin
Tarun Jha11-Dec-17 10:56
memberTarun Jha11-Dec-17 10:56 
GeneralRe: To take input for n number of arrays and print it. Pin
Tarun Jha16-Dec-17 5:41
memberTarun Jha16-Dec-17 5:41 
QuestionHow do I keyboard input in OpenGL Pin
Mr. Anup Roy1-Dec-17 3:57
professionalMr. Anup Roy1-Dec-17 3:57 
QuestionHow to get cpu speed and ram manufaturer C Languae? Pin
Uzair Ahmad12-Nov-17 4:56
memberUzair Ahmad12-Nov-17 4:56 
AnswerRe: How to get cpu speed and ram manufaturer C Languae? Pin
Afzaal Ahmad Zeeshan1-Dec-17 4:32
mvpAfzaal Ahmad Zeeshan1-Dec-17 4:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.180712.1 | Last Updated 16 Jul 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid