1. Question:Simple program of c find the largest number 

    Answer
    #include<stdio.h>
    int main(){
      int n,num,i;
      int big;
      
      printf("Enter the values of n: ");
      scanf("%d",&n);
     
      printf("Number %d",1);
      scanf("%d",&big);
    
      for(i=2;i<=n;i++){
        printf("Number %d: ",i);
        scanf("%d",&num);
    
        if(big<num)
          big=num;
      }
      
      printf("Largest number is: %d",big);
    
      return 0;
    }
    Sample Output: Enter the values of n: Number 1: 12 Number 2: 32 Number 3: 35 Largest number is: 35






    1. Report
  2. Question:Extract digits from integer in c language 

    Answer
    #include<stdio.h>
    int main(){
      int num,temp,factor=1;
    
      printf("Enter a number: ");
      scanf("%d",&num);
    
      temp=num;
      while(temp){
          temp=temp/10;
          factor = factor*10;
      }
    
      printf("Each digits of given number are: ");
      while(factor>1){
          factor = factor/10;
          printf("%d ",num/factor);
          num = num % factor;
      }
    
      return 0;
    }
    Sample output: Enter a number: 123 Each digits of given number are: 1 2 3






    1. Report
  3. Question:Count the number of digits in c programming language 

    Answer
    #include<stdio.h>
    int main(){
      int num,count=0;
    
      printf("Enter a number: ");
      scanf("%d",&num);
    
      while(num){
          num=num/10;
          count++;
      }
      printf("Total digits is:  %d",count);
      return 0;
    }
    Sample output: Enter a number: 23 Total digits is: 2






    1. Report
  4. Question:C code to count the total number of digit using for loop 

    Answer
    #include<stdio.h>
    int main(){
      int num,count=0;
    
      printf("Enter a number: ");
      scanf("%d",&num);
    
      for(;num!=0;num=num/10)
          count++;
    
      printf("Total digits is:  %d",count);
    
      return 0;
    }
    Sample output: Enter a number: 456 Total digits is: 3






    1. Report
  5. Question:Count the digits of a given number in c language using recursion 

    Answer
    #include<stdio.h>
    
    int countDigits(num);
    int main(){
      int num,count;
    
      printf("Enter a number: ");
      scanf("%d",&num);
    
      count = countDigits(num);
    
      printf("Total digits is:  %d",count);
      return 0;
    }
    
    int countDigits(int num){
        static int count=0;
    
         if(num!=0){
              count++;
             countDigits(num/10);
        }
    
        return count;
    }
    Sample output: Enter a number: 1234567 Total digits is: 7






    1. Report
Copyright © 2025. Powered by Intellect Software Ltd