Monthly Archives: January 2017

C Language: Inverted half pyramid using *

#include <stdio.h> int main() { int i, j, rows; printf("Enter number of rows: "); scanf("%d",&rows); for(i=rows; i>=1; --i) { for(j=1; j<=i; ++j) { printf("* "); } printf("\n"); } return 0; } OutPut: * * * * * * * *

C Language: Program to print half pyramid using alphabets

#include <stdio.h> int main() { int i, j; char input, alphabet = 'A'; printf("Enter the uppercase character you want to print in last row: "); scanf("%c",&input); for(i=1; i <= (input-'A'+1); ++i) { for(j=1;j<=i;++j) { printf("%c", alphabet); } ++alphabet; printf("\n"); }

C Language: Program to print half pyramid a using numbers

#include<stdio.h> int main() { int i, j, rows; printf(“Enter number of rows: “); scanf(“%d”,&rows); for(i=1; i<=rows; ++i) { for(j=1; j<=i; ++j) { printf(“%d “,j); } printf(“\n”); } return 0; } OutPut: 1 1 2 1 2 3 1 2 3

C Language: Program to print half pyramid using *

  #include <stdio.h> int main() { int i, j, rows; printf("Enter number of rows: "); scanf("%d",&rows); for(i=1; i<=rows; ++i) { for(j=1; j<=i; ++j) { printf("* "); } printf("\n"); } return 0; } OutPut: * * * * * * *

C Language: Factorial of a Number using For loop

The factorial of a positive number n is given by: factorial of n (n!) = 1*2*3*4….n *The factorial of a negative number doesn’t exist and the factorial of 0 is 1, i.e 0! = 1 #include <stdio.h> int main() {

C Language: Find Factorial of a Number Using Recursion

The factorial of a positive number n is given by: factorial of n (n!) = 1*2*3*4….n *The factorial of a negative number doesn’t exist and the factorial of 0 is 1, i.e 0! = 1 #include <stdio.h> long int fact(int

C Language: Find Factorial of a given Number

The factorial of a positive number n is given by: factorial of n (n!) = 1*2*3*4….n *The factorial of a negative number doesn’t exist and the factorial of 0 is 1, i.e 0! = 1 #include <stdio.h> int main() {

Translate »