Skip to main content

Posts

C program to check whether a number is Armstrong or not

Code 1: 1. Warp to check a number is Armstrong 2. C program to check whether a number is Armstrong or not 3. Simple c program for Armstrong number 4. Armstrong number in c with output #include <stdio.h> int main(){     int num,r,sum=0,temp;     printf( "Enter a number: " );     scanf( "%d" ,&num);     temp=num;     while (num!=0){          r=num%10;          num=num/10;          sum=sum+(r*r*r);     }     if (sum==temp)          printf( "%d is an Armstrong number" ,temp);     else          printf( "%d is not an Armstrong number" ,temp);     return 0; } Sample output: Enter a numb...

Reverse a string in c without using temp String reverse using strrev in c

Reverse a string in c without using temp String reverse using strrev in c programming language #include <stdio.h> #include <string.h> int   main(){       char   str[50];       char   *rev;     printf( "Enter any string : " );     scanf( "%s" ,str);     rev = strrev(str);         printf( "Reverse string is : %s" ,rev);           return   0; } String reverse in c without using strrev String reverse in c without using string function How to reverse a string in c without using reverse function #include <stdio.h> int   main(){       char   str[50];       char   rev[50];       int   i=-1,j=0;     printf( "Enter any string : " );     s...