Program to add digits of a number in C
#include <stdio.h> int main() { int n, sum = 0, remainder; printf(“Enter an integern”); scanf(“%d”,&n); while(n != 0) { remainder = n % 10; sum = sum + remainder; n … Read More
#include <stdio.h> int main() { int n, sum = 0, remainder; printf(“Enter an integern”); scanf(“%d”,&n); while(n != 0) { remainder = n % 10; sum = sum + remainder; n … Read More
#include <stdio.h> int main() { int i,j,rows; printf(“Enter the number of rows: “); scanf(“%d”,&rows); for(i=rows;i>=1;–i) { for(j=1;j<=i;++j) { printf(“* “); } printf(“n”); } return 0; } Output * * * … Read More
#include <stdio.h> int main() { int i,j,rows; printf(“Enter the number of rows: “); scanf(“%d”,&rows); for(i=1;i<=rows;++i) { for(j=1;j<=i;++j) { printf(“* “); } printf(“n”); } return 0; } Output * * * … Read More
#include stdio.h int main() { int a, b, x, y, t, gcd, lcm; printf(“Enter two integersn”); scanf(“%d%d”, &x, &y); a = x; b = y; … Read More
#include stdio.h int main() { int n, i, c, a = 1; printf(“Enter the number of rows of Floyd’s triangle to printn”); scanf(“%d”, &n);