c basic interview programs
c basic interview programs
while(tempNumber!=0) return 0;
{ }
rem=tempNumber%10; Output
sum=sum + (rem*rem*rem);
tempNumber/=10; Enter the value of N: 100
} Leap years from 1 to 100:
4 8 12 16 20 24 28 32 36
/* checking number is armstrong or not */ 40
if(sum==number) 44 48 52 56 60 64 68 72 76
printf("%d is an Armstrong number.",number); 80
else 84 88 92 96
printf("%d is not an Armstrong 9. C program to convert number from Decimal to
number.",number); Binary
#include <stdio.h>
return 0; int main()
} {
Output int number,cnt,i;
First run: int bin[32];
Enter an integer number: 153 printf("Enter decimal number: ");
153 is an Armstrong number. scanf("%d",&number);
Second run: cnt=0; /*initialize index to zero*/
Enter an integer number: 167 while(number>0)
167 is not an Armstrong number {
8. C program to print all Leap Year from 1 to N bin[cnt]=number%2;
#include <stdio.h> number=number/2;
//function to check leap year cnt++;
int checkLeapYear(int year) }
{ printf("Binary value is: ");
if( (year % 400==0)||(year%4==0 && year%100! for(i=(cnt-1); i>=0;i--)
=0) ) printf("%d",bin[i]);
return 1; return 0;
else }
return 0; Output
} Enter decimal number: 545
Binary value is: 1000100001
int main() 10. C program to convert number from Decimal to
{ Binary
int i,n; #include <stdio.h>
int main()
printf("Enter the value of N: "); {
int number,cnt,i; else
int bin[32]; printf("\n stringCmpi :String are not same.");