Join Regular Classroom : Visit ClassroomTech

October 2020

Coding Question 39

Write a C program to find the average of n numbers. #include<stdio.h> int main() { int num,i,count,sum=0; printf("n How many nos. you want tio add? "); scanf("%d",&count); for(i=0;i<count;i++) { printf("n Enter a Number: "); scanf("%d",&num); sum=sum+num; } printf("n Aveage= %.2f", (float)sum/(float)count); return 0; } Join Our Telegram Group Visit our Facebook Page Coding Questions Coding […]

Coding Question 39 Read More »

Coding Question 38

Write a program in C which prints the smallest divisor of an integer , for example smallest divisor of 77 is 7. #include<stdio.h> int main() { int num,i; printf("n Enter the number: "); scanf("%d",&num); for(i=2;i<=num;i++) { if(num%i==0) { printf("n %d is the smallest divisor of %d",i,num); break; } } return 0; } Join Our Telegram

Coding Question 38 Read More »

Coding Question 37

Write a function to sort the characters of the string passed to it as argument. #include<stdio.h> int main() { char c[100],ch; int i,j; printf("n Enter the String: "); gets(c); for(i=0;c[i]!=”;i++) { for(j=i+1;c[j]!=”;j++) { if(c[i]>c[j]) { ch=c[i]; c[i]=c[j]; c[j]=ch; } } } printf("n"); puts(c); return 0; } Join Our Telegram Group Visit our Facebook Page Coding

Coding Question 37 Read More »

Coding Question 36

Write two C programs that calculates factorial of a number using recursion and iteration. #include<stdio.h> int fact(int i) { if(i==0) return 1; if(i==1) return 1; return (i*fact(i-1)); } int main() { int i; printf("n Enter a number: "); scanf("%d",&i); printf("nFactorial of %d = %d ", i, fact(i)); return 0; } Join Our Telegram Group Visit

Coding Question 36 Read More »

Coding Question 35

Write a C-program to implement the Tower of Hanoi problem using recursion. C C #include <stdio.h>void towerfun(int, char, char, char);int main(){int n;printf(“Enter the number of disks : “);scanf(“%d”, &n);printf(“The sequence of moves involved in the Tower of Hanoi are :n”);towerfun(n, ‘A’, ‘C’, ‘B’); // A, B, C are towerreturn 0;} void towerfun(int n, char fr,

Coding Question 35 Read More »

Coding Question 34

Write a program to check a number is special or not. (Special is a number which is  equal to the sum of factorial of each digit of the given number). #include<stdio.h> int fact(int n) { int i,f=1; for(i=1;i<=n;i++) f=f*i;2 return f; } int main() { int num,sum=0,temp,r; printf("n Enter a number: "); scanf("%d",&num); temp=num; while(num!=0)

Coding Question 34 Read More »

Coding Question 32

Write a program to print Fibonacci series using recursive. #include<stdio.h> int fibo(int i) { if(i==0) return 0; if(i==1) return 1; return (fibo(i-1)+fibo(i-2)); } int main() { int i; for(i=0;i<10;i++) { printf("n %d ", fibo(i)); } return 0; } Join Our Telegram Group Visit our Facebook Page Coding Questions Coding Question :  Write a complete C

Coding Question 32 Read More »

Coding Question 31

Write a  recursive function to print the content of an array on reverse order, Write the main() function to call that recursive function.  #include <stdio.h> int main() { int n1; printf("Enter 1st integer: "); scanf("%d", &n1); reverse(n1); return 0; } void reverse(int num) { int temp,r,rev=0; temp=num; while(num!=0) { r=num%10; rev=rev*10+r; num=num/10; } printf("n Reverse

Coding Question 31 Read More »

Coding Question 30

Write a C program to find Greatest Common Divisor(GCD) for n number. #include <stdio.h> int main() { int n1, n2, i, gcd,lcm; printf("Enter 1st integer: "); scanf("%d", &n1); printf("Enter 2nd integer: "); scanf("%d", &n2); for(i=1; i <= n1 && i <= n2; i++) { if(n1%i==0 && n2%i==0) gcd = i; } printf("n G.C.D of %d

Coding Question 30 Read More »