Answers for "c programming basic interview questions"

C
0

c interview questions for experienced

#include <stdio.h>#include <conio.h>long factorial (int n){    if (n==0)    return 1;    else    return (n * factorial(n-1)); //recursion}void main(){    int number;    long fact;    printf("Enter a number: ");    scanf("%d", &number);    fact = factorial(number);    printf("The factorial of %d is %ld!\n", number, fact);    getch();}
Posted by: Guest on November-18-2020
-1

sample c programs for interview

/*C program to convert number from decimal to binary*/
 
#include <stdio.h>
 
int main()
{
    int     number,cnt,i;
    int     bin[32];
 
    printf("Enter decimal number: ");
    scanf("%d",&number);
 
    cnt=0;              /*initialize index to zero*/
    while(number>0)
    {
        bin[cnt]=number%2;
        number=number/2;
        cnt++;
    }
 
    /*print value in reverse order*/
    printf("Binary value is: ");
    for(i=(cnt-1); i>=0;i--)
        printf("%d",bin[i]);
 
    return 0;
}
Posted by: Guest on December-29-2019

Code answers related to "c programming basic interview questions"

Code answers related to "C"

Browse Popular Code Answers by Language